会话变量未更新?网络平台
我有一个三步向导。第一步,我使用中继器创建一系列可供个人选择的按钮。当用户选择其中一个按钮时,该按钮的值将保存到会话状态。他们将进入下一步,并显示基于他们之前选择的类似按钮列表。因此,如果您选择“汉堡”,您可能会收到“洋葱”、“生菜”、“番茄”选项,而如果您选择“热狗”,您可能会收到“酸菜”和“番茄酱”。 假设一个人选择汉堡包。这被保存到会话状态中,如下所示:
Public Sub Button_ItemCommand(ByVal Sender As Object, ByVal e As RepeaterCommandEventArgs)
' ******** Lets pass on the results of our query in LinqDataSource1_Selecting.
Session("food_select") = RTrim(e.CommandName)
Wizard1.ActiveStepIndex = 1
End Sub
现在,这工作得很好。但假设我选择了汉堡包,然后意识到我真的很想吃热狗。我返回到向导的第一个步骤并单击热狗按钮 - 但当向导进行到下一步时,我仍然看到汉堡包的选项!会话变量尚未更新。为什么? 谢谢!
I have a three step wizard. On the first step I use a repeater to create a series of buttons that an individual can select from. When the user selects one of the buttons the value of the button is saved to session state. They are taken to the next step and shown a similar list of buttons that are based on what they previously selected. Thus, if you choose "Hamburger" you might receive the options of "onion", "lettuce", "tomato" while if you choose "Hot Dog" you might receive "sauerkraut" and "ketchup".
Lets say an individual chooses Hamburger. This is saved into session state like so:
Public Sub Button_ItemCommand(ByVal Sender As Object, ByVal e As RepeaterCommandEventArgs)
' ******** Lets pass on the results of our query in LinqDataSource1_Selecting.
Session("food_select") = RTrim(e.CommandName)
Wizard1.ActiveStepIndex = 1
End Sub
Now, this works fine and dandy. But lets say I select hamburger and then realize I'm really hankering for a hot dog. I go back to the first wizard step and click on the hot dog button - but when the wizard progresses to the next step I still see the options for hamburgers! The session variable has not been updated. Why?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
会话变量可能已更新,但下一页仍从上次访问时缓存。
确保您的向导页面没有被缓存。
The session variable was probably updated, but the next page was still cached from the previous time it was accessed.
Make sure your wizard pages are not cached.
问题在于过早检查会话变量。我需要稍后在页面加载过程中移动它们 - 例如预渲染,然后会话变量将被更新。
Problem was in checking the session variables too early. I needed to move them later in the page load process - e.g. prerender, then the session variables would be updated.