How to upload a page of data to another page?

Source: Internet
Author: User
resquest.querystring--string used for <255
session--is used within this application.
application--the public for all startup applications.
cookies--writes the Dongdong to the client
cache--local applications do not want to cache data for a certain amount of time in order to read the database over and over again.
Passing values between two ASP.net pages
Introduction
Asp. NET provides an excellent event-driven programming model that allows developers to simplify the overall design of the application, but this also creates some of its inherent problems, for example, using the traditional ASP, we can easily deliver values between pages by using the Post method, the same thing, The asp.net of the event-driven programming model is not so easy, of course, we still have some ways to do the same. This article will try to solve this problem using different possible methods, but it is expected that this article will contain the use of querystring,session variables and the server. Transfer method to implement the value transfer between pages.
Using QueryString
Using querysting to pass values between pages is a very old mechanism, the main advantage of this method is very simple to implement, but its disadvantage is that the value passed is displayed in the browser's address bar (unsafe), but also can not pass the object, However, this approach is a good solution when the value is low and the security requirements are not high. The steps to use this method are as follows:
1, create a Web Form with a control (form)
2, create buttons and link buttons to return the form
3, create a character variable to save the URL in the Click event of a button or link button
4, add the QueryString parameter in the saved URL
5, use Response.Redirect to redirect to the URL saved above
The following code fragment demonstrates how to implement this method:
SOURCE page code:
private void button1_click
(object sender, System.EventArgs e)
{
string URL;
Url= "Anotherwebform.aspx?name=" + TextBox1.Text + "&email=" + TextBox2.Text;
Response.Redirect (URL);
}
Target page code:
private void Page_Load
(object sender, System.EventArgs e)
{
label1.text=request.querystring["Name"];
label2.text=request.querystring["email"];
}
Using the session variable
Using the session variable is another way to pass a value between pages, in this case we have the value in the control in the session variable and then use it in another page to implement the value transfer between different pages. However, it should be noted that in the session variable storage too much data will consume more server resources, in the use of sessions should be cautious, of course, we should also use some clean-up action to remove some unnecessary session to reduce the unnecessary consumption of resources. The general steps for passing values using session variables are as follows:
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.