I. Use POST to upload values
Asp file send. aspx
Copy codeThe Code is as follows:
<Form id = "form1" runat = "server" action = "receive. aspx" method = post>
<Div>
<Asp: Button ID = "Button1" runat = "server" OnClick = "button#click" Text = "Button"/>
<Asp: TextBox ID = "username" runat = "server"> </asp: TextBox>
</Div>
</Form>
Accept asp file receive. aspx
Copy codeThe Code is as follows:
String username = Ruquest. Form ["receive"];
1. Pass the value through the get Method
QueryString is also called a query string. The data to be transmitted in this method is appended to the webpage address (URL) for transmission. For example, when page A. aspx jumps to page B. aspx, you can use Request. Redirect ("B. aspx? Parameter Name = parameter value ") method, you can also use a hyperlink:, after the page jumps, you can use Ruquest [" parameter name "] on the target page to receive parameters. The QuerySting method is easy to implement and does not use server resources. The disadvantage is that the passed value is displayed on the address bar of the browser, which may cause tampering and cannot pass objects, it is feasible to query strings only when the URL request page is passed.
The following code snippet demonstrates how to implement this method:
Source Page code:
Copy codeThe Code is as follows:
Private void button#click (object sender, System. EventArgs e)
{
String url;
Url = "anotherwebform. aspx? Name = "+ TextBox1.Text +" & email = "+ TextBox2.Text;
Response. Redirect (url );
}
Target Page code:
Copy codeThe Code is as follows:
Private void Page_Load (object sender, System. EventArgs e)
{
Label1.Text = Request. QueryString ["name"];
Label2.Text = Request. QueryString ["email"];
}