Web 表单:在请求之间保持变量 [英] web forms: keep variables between requests
问题描述
这可能是初学者的问题,但如果我需要在 Web 表单中的请求之间保持变量的值,我有很多选择:
This is probably beginner's question, but if I need to keep variable's value between requests in web forms I have quite a bit of options:
- 写入隐藏的输入元素并在那里进位
- 在会话字典中保留值
- 在 ViewState 字典中保留值
- 可能还有一些我不知道的事情
那么,Web 表单中的正确方法是什么?(我需要在对同一页面的请求之间保持价值)
So what is the right way in web forms? (I need to keep value between requests to the same page)
推荐答案
您应该阅读以下内容:http://msdn.microsoft.com/en-us/library/75x4ha6s.aspx.MSDN 文章列出了可以保存会话状态的所有可能方式.
You should read this: http://msdn.microsoft.com/en-us/library/75x4ha6s.aspx. The MSDN articles list all the possible way you could save the state of you session.
如果您只想在回发之间保存控件的状态,您应该使用 ViewState一>.
If you just want to save the state of your controls between postback, you should use ViewState.
这篇关于Web 表单:在请求之间保持变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!