Because the Web page form is submitted to itself, the callback function is completed, so it is not possible to use post for multiple page values by default.
1. Using querystring, such as ...? id=1; Response. Redirect () ....
The transferred value is displayed in the address bar of the browser and cannot be passed in an array or object. Simple to use, it is very effective to pass a number or text value when the security requirements are not high.
Method of use: 1. in the code of the source page, construct the name and value that you want to pass URL address.
2. in the source page code with Response.Redirect (URL); REDIRECT to the above URL address.
3. the code on the destination page uses request.querystring["name"]; removed URL the value passed in the address.
2. Use the session variable
Acting on the user's personal, so, excessive storage will cause the server memory resource exhaustion, easy to lose. Simple to use, not only to pass simple data types, but also to pass objects. The size of the data volume is unlimited.
How to use:
1. Create the name and value you need to pass in the code of the source page construct the Session variable : session["name"]= "Value (Or Object)";
2. the code in the destination page uses the Session variable to remove the passed value. Result = session["Name"]
Note: Thesession can be destroyed when not used, the method is: Clear one:session.remove ("session name ");
Clear all:session.clear ();
3. Use of cookies
Cookies are used to store small pieces of information in the user's browser, to save information about the user, such as the user's ID when accessing a website , the user's preferences, etc., and the user can retrieve the previous information through the next visit. Cookies are passed back and forth between the browser and the server via an HTTP header. a Cookie can contain only the value of a string.
Cookies are stored on the client, and the session is stored on the server side. and The use of cookies should be used in conjunction with the asp .
A very common way to maintain user state. For example, in a shopping site, users can use it to maintain user status when they cross multiple page forms.
Method of use: 1. Create the name and value constructs that you need to pass in the code of the source page Cookies object ;
2. The code on the destination page uses the Cookie object to remove the value passed:Result = request.cookies["MyCookie"]. Value;
Consume less server resources, not only to pass simple data, but also to pass objects. The size of the data volume is unlimited. Variables used by individual users are generally not application.
4. Using Application
The scope is the entire global, which means it is valid for all users. It is valid throughout the application life cycle. It can be accessed from different pages.
It differs from the Session variable in that the former is a global variable shared by all users, and the latter is a unique global variable for each user.
Method of Use:1. Create the name and value constructs that you need to pass in the code of the source page Application variables : application["Nmae"]= "Value (Or Object)";
2. The code on the destination page uses the application variable to remove the passed value. Result = application["Nmae"]
Note: The common lock and unlock methods are used to lock and unlock, in order to prevent concurrent modifications.
private void Page_Load (object sender, EventArgs e)
{
String name;
Application.Lock ();
Name = application["Name"]. ToString ();
Application.UnLock ();
}
5. Using Server.Transfer
Its useServer.Transfermethod directs the process from the current page to another page, and the new page uses the reply stream of the previous page, so this method is a full-face object。 Server.Transferis from the currentASPXpage go to the newASPXpage, the server side executes the new page and outputs,in the new page byContext.Handlerto get the values of the various data types passed by the previous page, the form data,QueryString.Because the redirection is complete on the server side, the client browserURLthe address is not changed. CalledServer.Transfer, the currentASPXthe page terminates execution and the execution process is transferred to anotherASPXpage, but the newASPXThe page still uses the previousASPXthe reply stream created by the page.
PS : Compare Server.Transfer and the Response.Redirect the difference.
(1) Server.Transfer is done on the server side, so the client browser URL the address is not changed; Response.Redirect is the client completes a new page processing request to the server side, so the client browser URL the address will change.
(2) Server.Transfer done on the server side , The client is not required to make a request, and the client is reduced to the server side.
(3) Server.Transfer can only jump to a page specified by a local virtual directory , Which is the page in the project, and Response.Redirect are very flexible , can jump to any URL address.
(4) Server.Transfer you can upload various types of values from the previous page to the new page; Response.Redirect you can only use URL medium with parameters or in combination with the above four ways to upload various types of values to the new page.
You can pass values for various data types and values for controls. 1. The URL address in the client browser is not changed and can cause some unexpected problems in the new page. For example, if the source page and the destination page are not in the same virtual directory or its subdirectories, the use of relative path of the picture, hyperlink will lead to an error point.
Method of Use:1. in the code of the source page, use the Page Class of Server.Transfer jump to another page to pass the page data: Server.Transfer ("B.aspx", "false") .
2. on the destination page, use context.handler to receive data:formerpage formerpage = (formerpage) Context.Handler; then use The properties and methods of the formerpage to get the value of the previous page, or use the context.items["Myparameter" directly)
6 Using the HttpContext Item property
7. Working with files
8. Use a database, store temporary data through a database, and more.
9. Use the cache
Http://www.cnblogs.com/zhangkai2237/archive/2012/05/06/2486462.html
1. URL value This is a classic way of passing a value, which is very simple to use, but the value passed is displayed on the address bar of the browser and cannot be passed on to the object.
This method is typically used in cases where the value of the pass is low and the security requirement is not high. The
can use hyperlink text to pass values in *.aspx page development, as shown in the following code.
<asp:hyperlink runat= "Server" id= "Hplink"
Navigateurl= "~/getvalues.aspx?urlvalue1=intel&urlvalue2= AMD ">url value </asp:HyperLink>
The above link text jumps the page to the Getvalues.aspx page and passes the urlvalue1 variable and the urlvalue2 variable by URL, with the values of Intel and AMD respectively.
in *.cs's server-side methods, you can also call the redirect method of the HttpResponse object, directing the browser end multiplicity to the new page and passing the value through the URL, as shown in the following code.
Response.Redirect ("~/GETVALUES.ASPX?URLVALUE1=INTEL&URLVALUE2=AMD");
3. Cookie-based cookies are a special way of storing data in a way that stores data in a browsing user's computer and is present on disk as a text file.
This is a very interesting way, many login system is to use cookies to enable users to automatically log in. The login information that the user logs in once will be written to the cookie file of the user's computer.
The next time you log on, the Web site automatically reads the cookie to complete the authentication. Although it is convenient to pass the data through a cookie, the save time can be set freely, but the security is not high,
Programmers should not rely too much on cookies, but should use a combination of methods to complete the storage of sensitive data.
Asp. The main types of operating cookies in net are under the System.Web namespace, HttpCookie, HttpResponse, and HttpRequest, respectively.
HttpCookie can establish and manipulate the security type of a standalone cookie, access the HttpResponse and HttpRequest cookie properties to get the HttpCookieCollection collection object, To read or add a HttpCookie object.
6. The transfer method of cross-page routing and invocation of HttpServerUtility objects is similar, but more efficient.
Because the transfer method that calls the HttpServerUtility object is a server-based approach, cross-page delivery is browser-based.
The main method is to set the control's "PostBackUrl" property so that the control, such as a button, moves to the specified page after the operation.
And this specified page can fetch all the control objects and their property values of the previous page directly.
Assuming that the first page is sendvalues.aspx, add two controls to the page (not the *.cs code file), as shown in the following code.
<asp:textbox runat= "Server" id= "Pbvalue" text= "Geforce TX280" >
</asp:TextBox> <asp:button runat= "Server" id= "Btn6" text= "cross-page transfer" postbackurl= "~/getvalues.aspx"/>
In the above code, the TextBox control's "Text" property is "Geforce TX280", which is the value that needs to be transferred.
The button control's PostBackUrl property specifies the Getvalues.aspx page, which receives the value that is required to be passed.
In GetValues.aspx.cs's Page_Load method, write the following code.
PreviousPage the page that transports the control to the current page
if (previouspage! = null)
{
Search for the control "ID" as pbvalue from the PreviousPage container and convert it to a textbox type
TextBox TB = (textbox) Previouspage.findcontrol ("Pbvalue");
If TB is not a null reference
if (TB! = NULL)
{
Give the TB "Text" attribute value to the str variable, string str = tb. Text;
}
}
The code above easily obtains the "Text" property value of the TextBox control in the previous page, which is quicker than the transfer method of invoking the HttpServerUtility object and reduces the processing steps.
Http://zhidao.baidu.com/link?url=x0i9x9icxJLeP94ruG1Xe_v1_ 5yjz-wpa8p7vs7owuq5vbl9rypokclb0a2niewtugpurp9uhpde5t8hbuv5ateusdutw9sneqm_d0oxyno
http://blog.csdn.net/zengjibing/article/details/3915902
Several ways to list the values passed between ASP.