1 Url传值:
2 Session
3 Cookie
4 Application
5 Response.Redirect()传值
6 最后在另外一个页面获得当前页面的控件中的值,在这里重点讲一下
首先在asp.net中只有Button linkButton imgButton有postbackUrl属性可以用来跨页传递控件的值
|
以下是代码片段: <asp:Button ID="Button1" runat="server" Text="Button" PostBackUrl="index.aspx" /> Index.aspx: if(Page.PreviousPage!=null) { if(Page.PreviousPage.IsCrossPagePostBack) { TextBox textControl=this.PreviousPage.FindControl("TextBox1") as TextBox; if(textControl.Text!=null) { this.Label1.Text = textControl.Text; } } } |
PreviousPage:代表传递值的页面
IsCrossPagePostBack:判断页面是不是跨页传值
FindControl:获得控件的值