300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > Asp.net页面传值

Asp.net页面传值

时间:2023-08-22 21:24:21

相关推荐

Asp.net页面传值

中的页面传值方法:

1Url传值:

2Session

3Cookie

4Application

5Response.Redirect()传值

6最后在另外一个页面获得当前页面的控件中的值,在这里重点讲一下

首先在中只有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:获得控件的值

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。