Summary of common methods of ASP. NET page value transfer
- 2020-06-23 00:11:23
- OfStack
1. Form Submission:
<formaction= "target.aspx" method = "post" name ="form1">
<input name = "param1" value ="1"/>
<input name = "param2" value ="2"/>
</form>
....
form1.submit();
....
This method is generally used in html pages and not in asp.net, because the form of asp.net is always submitted to its own page.
2. Link mode of A tags
<Ahref="target.aspx?param1=1¶m2=2"> Link address transfer </A>
Receiving page: string str = Request["param1"]
3. Session sharing
Send page: Session("param1") = "1";
According to close the page string str =Session("param1").ToString();
4. Application sharing
Send page: Application("param1") = "1";
Click to receive page: string str = Application("param1").ToString();
This approach is not often used because Application is Shared across 1 application domain and all users can change and set its value, so only apply where global variables such as counters are required.
5. Cookie
6. Response. Redirect () method
Response.Redirect("target.aspx?param1=1¶m2=2")
Receiving page: stringstr = Request["param1"]
7. Server. Transfer () method
Server.Transfer("target.aspx?param1=1¶m2=2")
Receiving page: stringstr = Request["param1"]