I. Use POST to upload values
Asp file send. aspx
| The code is as follows: |
Copy code |
|
<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
| The code is as follows: |
Copy code |
|
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:
| The code is as follows: |
Copy code |
|
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:
| The code is as follows: |
Copy code |
|
Private void Page_Load (object sender, System. EventArgs e)
{
Label1.Text = Request. QueryString ["name"];
Label2.Text = Request. QueryString ["email"];
} |