如何在asp.net中禁用viewstate [英] how to disable viewstate in asp.net

查看:103
本文介绍了如何在asp.net中禁用viewstate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用enableviewstate = false

禁用视图状态到我的文本框控件但仍然在发布back后保留其值的文本框。完全禁用viewstate

解决方案

Quote:

为什么某些控件即使在禁用ViewState后仍会保留值,而其他控件却没有?



答案是实现IPostBackEventHandler的控件,如Textbox,Checkbox等,即使在禁用viewstate后也会保留状态。原因是在Load Postback Data阶段,这些控件将从Posted back形式获取状态信息。



但是像label这样没有实现IPostBackEventHandler的控件将不会获得任何来自发布的数据的状态信息因此完全取决于viewstate以维持状态。



ViewState和Postback [ ^ ]


i disable view state to my text box control using enableviewstate=false
but still textbox retaining its value after post back.how to completely disable viewstate

解决方案

Quote:

Why some controls retain values even after disabling the ViewState while others do not?

The answer is Controls which implements IPostBackEventHandler like Textbox, Checkbox, etc. will retain the state even after disabling the viewstate. The reason is during the Load Postback Data stage, these controls will get state information from Posted back form.

But controls like label which do not implement IPostBackEventHandler will not get any state information from posted back data and hence depend entirely on viewstate to maintain the state.


ViewState and Postback[^]


这篇关于如何在asp.net中禁用viewstate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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