First, the use of post transmission value
Transfer Value ASP file send.aspx
Copy Code code as follows:
<form id= "Form1" runat= "Server" action= "receive.aspx" method=post>
<div>
<asp:button id= "Button1" runat= "Server" onclick= "Button1_Click" text= "button"/>
<asp:textbox id= "username" runat= "server" ></asp:TextBox>
</div>
</form>
Accept ASP File receive.aspx
Copy Code code as follows:
String username = ruquest.form["Receive"];
One, get method pass value
QueryString is also called a query string, which is passed after the page address (URL) is appended to the data. such as page a.aspx jump to the page b.aspx, you can use Request.redirect ("b.aspx? parameter name = parameter value") method, you can also use hyperlinks:, page jump, in the target page to be available ruquest["parameter name" to receive parameters. The advantage of using the Querysting method is that it is simple to implement and does not use server resources; The disadvantage is that the value passed is displayed in the browser's address bar, there is a risk of tampering, cannot pass the object, only the query string is feasible when the page is requested through the URL
The following code fragment demonstrates how to implement this method:
SOURCE page code:
Copy Code code as follows:
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:
Copy Code code as follows:
private void Page_Load (object sender, System.EventArgs e)
{
label1.text=request.querystring["Name"];
label2.text=request.querystring["email"];
}