asp.net viewstate--application

Source: Internet
Author: User

View state is definitely a headache for asp.net developers, especially those who are interested in control development. All along, I have been very confused, searching the internet for a long time, these two days only a little bit of perspective. And since I have been diving, I decided to take the first bubble today.

When we derive new controls from control or WebControl, we can use the Modifier property without defining the ViewState attribute, so it should be derived. When we look at the source code with reflector, we know that it's in control.

Protected virtual StateBag ViewState
{
get
{
.
}
set
{
}
}  

Here comes a new type of statebag, what is it? Let's start with the source code:

StateBag from System.Web.UI, its statement is as follows:

Public sealed class Statebag:istatemanager, IDictionary, ICollection, IEnumerable .....

Here we focus on istatemanager, because we need to derive from this interface when we customize view state management for our custom controls. But this time I'm not going to talk about it.

By name, we can generally think of it as a container, a container of ' state '.

Let's look at the implementation of StateBag:

Private IDictionary bag;
private bool marked;
Public StateBag (bool ignoreCase)
{
this.marked = false;
This.ignorecase = ignoreCase;
This.bag = this.    Createbag ();
private IDictionary createbag ()
{return
new HybridDictionary (this.ignorecase);
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.