ASP.NET web design common code

xiaoxiao2021-03-06  14

Switch between webpages

Making multiple web pages, in addition to how to pass the data, you must also understand how to switch the web.

In the ASP.NET program, there are two ways to switch the webpage: response.redirect ('' ") Server.Transfer (''. ASPX web")

The difference between Response.Redirect and Server.Transfer is: 1. For Response.Redirect, as long as it is a web page, it can be switched objects. 2. For Server.Transfer, you can only switch to the .aspx web page with the same directory or a subdirectory. 3, Response.Redirect Switch to another web page, the browser's address will display the new URL, but after server.transfer switches to another web page, the browser's address still displays the old URL, and the server.transfer has a confidential function.

Data transfer between webpages

The data conveying between the webpage refers to the old web page delivery to the new web page when switching to a new web page.

1 Call server.urlenCode (variable) encodes the data to be passed.

2 Therefore, when the data to be transmitted exceeds 2 KB, it is necessary to use Server.Transfer.

SESSION object Basic properties and methods

Session Objects Common Properties: All Returns all session object variables to a array count Returns the number of session object variables to return or set sessionTINTIMEOUT to return or set sessionTimeout to return or set the effective time of the session object variable, when online users If there is no action over the effective time, the session object is invalid, the default is 20 minutes.

SESSION object common method: add Add a session object Variable Clear Clear all session object Variable Remove to remove all Session object variables with variable name to remove all session object variables

Get the value of the session: session ('' variable name ') = value

Get the path to the current browsing web page

The REQUEST object provides the mappath method and the Path property. For the server to learn about the path to the webpage recently.

Use the mappath method to receive a parameter of a string type and return the current actual path and a combination with the incoming string.

For example: Request.mAppath ('' aa.aspx '')

Text box input limit