Home > Backend Development > C#.Net Tutorial > Summary of common methods of passing values ​​in ASP.NET pages

Summary of common methods of passing values ​​in ASP.NET pages

高洛峰
Release: 2017-01-21 14:46:03
Original
1115 people have browsed it

1. Form submission:

<formaction= "target.aspx" method = "post" name ="form1"> 
<input name = "param1" value ="1"/> 
<input name = "param2" value ="2"/> 
</form> 
.... 
form1.submit(); 
....
Copy after login

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"]
Copy after login

3. Session sharing

发送页面:Session("param1") = "1"; 
按收页面 string str =Session("param1").ToString();
Copy after login

4. Application sharing

发送页面: Application("param1") = "1"; 
按收页面: string str = Application("param1").ToString();
Copy after login

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"]
Copy after login

7. Server.Transfer() method

Server.Transfer("target.aspx?param1=1¶m2=2") 
接收页面: stringstr = Request["param1"]
Copy after login

More ASP.NET For a summary of common methods of page value transfer, please pay attention to the PHP Chinese website for related articles!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template