Order of precedence in setting properties in asp.net
Some settings in asp.net like viewstate can be controlled at the site (web.config), page, or control levels. What is the order of precedence? What happens, for example, if I set viewstate of site and page levels but on at the control level?
Also, is viewstate for a control the same as control state?
Furthermore, what events to use for loading and saving viewstate for controls (is this the same thing as control state?) and also for custom controls?
- Similarly, which events should I use t开发者_运维百科o render controls? Is this PreInit and Load? Is this the same for custom controls?
Thanks
There are a lot of questions here. What you need is something like this:
Understanding ASP.NET Viewstate
To answer your first question... ViewState is enabled by default. The precedence goes like this:
web.config will disable viewstate everywhere
@Page directive will disable viewstate for that page
@Control directive will disable viewstate only for that control
Actually, now that I think about it... this is an interesting question. Are you just setting a new default at the web.config or Page level; can it be overridden by a Control? An experiment is in order.
精彩评论