无法获取会话变量和文本框的更新值 [英] Unable to get updated value of session variable and Textbox

查看:122
本文介绍了无法获取会话变量和文本框的更新值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在asp.net和c#中构建一个Web应用程序,我将文本框的文本存储在Session变量中,如下所示:

I am building a web application in asp.net and c#, I am storing text of textbox in Session variable like this:

Session["data"]=TextBox1.Text;

在按钮单击事件上,我将用户重定向到另一页.在第二页中,我使用此变量 Session ["data"] ,在page2中,我所在的位置是一个后退按钮再次重定向到存在textbox1的page1.现在在按钮单击事件上,我将重定向到page2,该事件是这样的代码,

and on the button click event I am redirecting user to another page.In the second page I am using this variable Session["data"] and in page2 there is a back button where I am again Redirecting to page1 where the textbox1 is present.Now on the button click event where I am redirecting to page2 and event is code like this,

Session["data"]=TextBox1.Text;
Response.Redirect("page2.aspx");

现在当我访问Session ["data"]的值时,它给了我以前的值.由于TextBox1的内容可能会更改,因此这些更改未显示.

now when I am accessing the value of the Session["data"] it is giving me the previous value.As the content of TextBox1 may get changed,these changes have not been shown.

请告诉我我要去哪里了

推荐答案

我不认为您使用的代码很破旧.请创建一个断点,然后再次检查该值是否正确分配或者您只需将会话设置为null,然后在click事件上为其分配文本框值即可.

I dont think the code you are using is worng. You please make a break point and check it again that the values are assigning correctly Or You just set the session to null and then assign the textbox value to it on the click event.

这篇关于无法获取会话变量和文本框的更新值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆