views:

45

answers:

2

What is the advantage of using control state instead of view state when I create a custom control in ASP.NET?

Why use control state?

Does a good article about this exist?

+1  A: 

http://msdn.microsoft.com/en-us/library/1whwt1k7.aspx has some explanation of when to use each.

uosɐſ
+1 i have give for the link but i already visited this link but any ways thanks for this info
Pranay Rana
+1  A: 

The difference between ViewState and ControlState is that ViewState can be disabled by the developer, whereas ControlState cannot be disabled.

Therefore, when developing custom controls, when to use ViewState or ControlState ?

  • Essential data which has to persist across postbacks with ViewState disabled and which is necessary for the proper functioning of the custom control should be put into ControlState.
  • All other data: use ViewState.

Typically, if the persistence of the data can be viewed as a feature, use ViewState. For example, in some scenarios, it is convenient when a DropDownList saves all its items in ViewState, and in other scenarios it is preferable to just rebind the control (and keep the page size and amount of data to post low).

marapet