asp.net method of parameter value between page and page

Source: Internet
Author: User

  This article mainly introduced the ASP.net page and the page to pass the parameter value method, explained the post pass value and get passes the value the use method, needs the friend to be possible to refer to under

First, the use of Post value   transfer ASP file send.aspx     code is as follows: <form id= "Form1" runat= "Server" action= "receive.aspx" method= post>     <div>         <asp:button id= "Button1" runat= "Server" onclick= "button 1_click "text=" button "/> <asp:textbox id=" username "runat=" server "></asp:TextBox> </div> </ Form>     Accept ASP file receive.aspx   code as follows: string username = ruquest.form["Receive"];     One, get method transfer value   QueryString also called query string, this method will be passed the data appended to the Web page address (URL) to pass. 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 requesting the page through the URL   The following code snippet demonstrates how to implement this method:   Source page code:     Code as follows: private void Button1_Click (object sender, System.EventArgs e) {s    Tring URL;    Url= "Anotherwebform.aspx?name=" + TextBox1.Text + "&email=" + TextBox2.Text; Response.Redirect (URL); }   &NBsp Target page code:     Code is as follows: private void Page_Load (object sender, System.EventArgs e) {label1.text=request.querystring[    "Name"]; label2.text=request.querystring["email"]; }  

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.