asp.net加载回发数据并引发回发事件viewstate交互
我正在阅读以更好地了解 viewstate 在 asp.net webforms 中的工作原理,并且一直在阅读 这篇文章。
我不太明白的一部分是第 5 阶段 - 引发回发事件,它表示此阶段不使用任何视图状态信息来引发事件(即 TextChanged)。
我认为视图状态将与回发时的页面一起发送回,并且在填充控件树之后,视图状态中的值将被加载,然后控件将询问新的表单值,将它们与当前的值进行比较从视图状态加载的,以便告诉它需要引发哪些 Changed() 事件。
如果此事件不与视图状态交互,它如何判断值是否已更改或与之前的加载相同?
I'm reading up to get a better idea of how viewstate works in asp.net webforms and have been reading this article.
One part that I don't quite understand is the Stage 5 - Raise postback event, it says that this stage does not make use of any viewstate information to raise the events (ie. TextChanged).
I thought that the viewstate would be sent back with the page on the postback and after the control tree had been populated the values from the viewstate would then be loaded in and then after that the control would interrogate the new form values comparing them against the current ones loaded from viewstate in order to tell which Changed() events it needs to raise.
If this event doesn't interact with viewstate how can it tell whether a value has changed or if it is still the same from the previous load?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
丹尼尔,您的假设是正确的 - 视图状态用于确定是否需要引发与更改相关的事件。其中包括 TextBox 上的
TextChanged
事件和 DropDownList 上的SelectedIndexChanged
事件等。如果您还没有阅读本文,我强烈推荐您阅读:真正了解视图状态。这是 Dave Reed 撰写的内容丰富的文章。
谢谢!
Daniel, you are correct in your assumption - view state is used to determine whether a change-related event needs to be raised. That includes things like the
TextChanged
event on the TextBox and theSelectedIndexChanged
event on the DropDownList, among others.If you haven't read this article yet, I highly recommend it: Truly Understanding View State. It's an informative write up by Dave Reed.
Thanks!
在 TextChanged 事件的情况下,它会查看视图状态以确定它是否被引发 - 请参阅 问题 6215046:
http://msdn.microsoft.com/ en-us/library/system.web.ui.webcontrols.textbox.ontextchanged.aspx
尝试为 TextBox 启用 ViewState。
In the case of TextChanged events, it does look at the viewstate to determine if it gets raised or not - see the answer to question 6215046:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox.ontextchanged.aspx
Try enabling ViewState for TextBox.