| |

VerySource

 Forgot password?
 Register
Search
View: 1096|Reply: 8

Asp.net how to solve the logical display of the page?

[Copy link]

2

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-2 18:20:01
| Show all posts |Read mode
Passed a parameter, I need to judge this parameter to decide what content to display on the page. In asp, usually add <% If Then .. in the HTML, but asp.net pays attention to the separation of the page from the code, what is there Good solution?
Reply

Use magic Report

0

Threads

18

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-1-2 18:21:01
| Show all posts
The same under ASP.NET, you can use a ternary operator to judge ...
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-2 22:00:01
| Show all posts
asp.net can also be used
<% if (bool)%> <%%>
Of the mechanism.
The separation of page and code in asp.net mainly lies in the separation of response events and background.
If you need to display different pages based on a Boolean value, it should still be the same as the asp mechanism.
Reply

Use magic Report

0

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-1-2 22:48:01
| Show all posts
But asp.net pays attention to the separation of pages and code, what are the good solutions?
-------------------------------------------------- -
This is better achieved, the foreground <% = str%> background: public string str; if (judgment) {str = "1"} else {str = "2"}
Reply

Use magic Report

2

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-1-6 10:21:01
| Show all posts
The content I want to display is a large piece of HTML code.For example, when you develop the background, you may make a frame set, or the value passed is news, and you will add news information in the main.aspx page. For example, adding news (this is HTML), maybe the menu is passed over, and you will display the menu information (also paragraph HTML) in main.aspx, then I put all the HTML in main.aspx, which is the same as ASP Put <% if (act == "news") {%> HTML <%} if (act == "menu") {%> HTML <%}%> together ???
Reply

Use magic Report

0

Threads

15

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-6 14:51:01
| Show all posts
asp.net is also compatible with asp. The code is the same.
Just a slight adjustment in syntax.
Reply

Use magic Report

0

Threads

64

Posts

35.00

Credits

Newbie

Rank: 1

Credits
35.00

 China

Post time: 2020-1-6 15:03:01
| Show all posts
for example:

void page_load (object sender, eventArguments e)
{
    .....
    string ucname = Reuqest.QueryString ["param"];
    if (ucname! = null)
    {
        Control uc = this.LoadControl (ucname);
        uc.ID = "UserDefinedArea";
        this.thePlaceHolder.Controls.Add (uc);
    }
}
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-8-24 12:30:01
| Show all posts
Let me ask you a question. Asp.net distinguishes logic from display, but for example, I want to implement such a function, how do you want to achieve it? For example, I set the corresponding data source in aspx.cx of the control logic. Then set the display position of the data in the corresponding data source on the displayed aspx, but for example, I want to use the relevant data in the data source to make a judgment, and then control the display results on the corresponding aspx, such as I get a certain field The value is 0, then I can increase the display on the page displayed to the user, and there is a corresponding link, when the value of the obtained field is 1, then I display the browse on the page displayed to the user, and provide the corresponding Of course, the last displayed to the user is a number of records, not just one, you said how to achieve, thank you.
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-8-24 12:45:01
| Show all posts
But what I want to change is to look at the specific values ​​in the user database to determine the corresponding display content on the last page displayed to the user. Asp used to be controlled by if then else in the display page, but I don’t know where aspx.cs is where logic and presentation layer are separated. I don’t know where to put if then else here, I just put it In the presentation layer, a prompt error was found,
<td>
                                        <%# if (DataBinder.Eval(Container.DataItem, "auditflag")==0)
                                             %>
                                             Incomplete content
                                        <%else if (DataBinder.Eval(Container.DataItem, "auditflag")==1)
                                             %>
                                           Pending
                                           <%else if (DataBinder.Eval(Container.DataItem, "auditflag")==2)
                                             %>
                                           Audit failed
                                           <%else if (DataBinder.Eval(Container.DataItem, "auditflag")==3)
                                             %>
                                           examination passed
                                           &nbsp;</td>
You see where the problem is, thank you.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list