Home > Article > Backend Development > Summary of common methods of passing values in ASP.NET pages
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, not in asp.net, because asp.net forms are always submitted to their own pages.
2. Linking method of A tag
<Ahref="target.aspx?param1=1¶m2=2">链接地址传送</A> 接收页面: string str = Request["param1"]
3. Session sharing
发送页面:Session("param1") = "1"; 按收页面 string str =Session("param1").ToString();
4. Application sharing
发送页面: Application("param1") = "1"; 按收页面: string str = Application("param1").ToString();
This method is not commonly used because Application is shared within an application domain, and all users can change and set its value, so only counters and other places that require global variables are used.
5. Cookie
6. Response.Redirect() method
Response.Redirect("target.aspx?param1=1¶m2=2") 接收页面: stringstr = Request["param1"]
7. Server.Transfer() method
Server.Transfer("target.aspx?param1=1¶m2=2") 接收页面: stringstr = Request["param1"]
More ASP.NET For a summary of common methods of page value transfer, please pay attention to the PHP Chinese website for related articles!