Asp.net 将值从 txtbox 传递到另一个页面 [英] Asp.net pass value from txtbox to an another page
本文介绍了Asp.net 将值从 txtbox 传递到另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码到此结束
...
If lblErrMsg.Text = "" Then
Response.Redirect("UserPage.aspx")
End If
我想将 txtUser 的值(我在当前页面中创建它...)传递给 UserPage.aspx.
I want to pass the value of txtUser(I create It in the current page...) to the UserPage.aspx.
感谢帮助我...
这是在 VB.net 中而不是在 c# 中,请
This is in VB.net not in c# Please
推荐答案
C# 版本
1) 使用查询字符串
Response.Redirect("user.aspx?val="+txtBox.Text);
在 userp.aspx.cs 中,
and in userp.aspx.cs,
string strVal=Request.QueryString["val"];
2)使用会话
在重定向前在第一页设置会话
Setting session in first page before redirecting
Session["val]=txtBox.Text;
Response.Redirect("user.aspx");
并在 user.aspx.cs 中
and in user.aspx.cs
String strVal=(string) Session["val"];
VB.NET 版本
1) 使用查询字符串
Response.Redirect("user.aspx?val=" + txtBox.Text)
并在 user.aspx.vb
and in user.aspx.vb
Dim strVal As String = Request.QueryString("val")
2)使用会话
在首页设置会话
Session("val")=txtBox.Text
Response.Redirect("user.aspx")
并在 user.aspx.vb 中.
and in user.aspx.vb.
Dim strVal As String = DirectCast(Session("val"), String)
这篇关于Asp.net 将值从 txtbox 传递到另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文