如何在asp.net中将页面值从一页传递到另一页 [英] How to Pass Page Values from one page to another page in asp.net
问题描述
您好,我在网络表单中有一个登录页面,并且如果成功输入了用户名和密码,并且当用户单击提交按钮时,我需要输入必须在另一页中显示在登录页面中输入的用户名".如何使用Response.Redirect()完成上述方案.任何帮助将是Thankfull.
jagan
Hi, I''ve a Login Page in my webform & if UserName & Passwords r successfully entered & when User clicks on submit button I need to be "The UserName entered in Login Page must be displayed in another Page" . How to do the above scenario with Response.Redirect(). Any Help would be Thankfull.
jagan
推荐答案
使用会话存储此类值.您可以将其检索到下一页.
示例:
Hi,
Use Session to store such values. You could retrieve it to your next page.
Example:
Session["UserName"] = "My Name";
然后在xt页面上,您可以取回汽车,例如:
then on thext page you car retrieve such as:
string useName = Session[UserName"].ToString();
祝您编程愉快...
Happy coding...
朋友,
有多种方法可以做到.
1)使用Session对象.身份验证完成后,您将在会话中存储用户名,并在另一页上获取它.
喜欢,
设置会话变量.
Hi Friend,
there are multiple way''s you can do it.
1) using Session object . once authentications is done then you will Store user name in Session and get it on another page.
LIke ,
Set Session variable.
Session["username"] = " your user name variable";
获取会话变量
Get session variable
string username = Session["username"].tostring();
2)使用查询字符串.
您可以将用户名传递到url中的查询字符串中
像
设置查询字符串值
2) using Query string.
you can pass user name into Query string in url
Like
Set Query string value
responce.Redirect("username.aspx?value="+ username);
在另一页上获取质量检查
get QS on another page
if (Request.QueryString("value") != null)
{
string username = Request.QueryString("value").tostring();
}
还有其他方法可以在两个页面调用之间传递值.以上两种方法最常用.
希望这对您有帮助...
there are also other ways to pass the value between two page call. above two method are mostly used.
hope this will help...
您可以使用以下任何一种方法来传输值
- 查询字符串
- Cookies
- 会话变量
- Server.Transfer
- 回发URL
You may use any of below ways to transfer values
- Query Strings
- Cookies
- Session variables
- Server.Transfer
- Post Back URL
这篇关于如何在asp.net中将页面值从一页传递到另一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!