Joby Kurian
Joby Kurian

Reputation: 3927

User control with viewstate enabled but placed inside page with viewstate disabled.How can i access?

I have a user control, with viewstate enabled. i am using it on a page with viewstate disabled.How can I access viewsate info?

Upvotes: 0

Views: 263

Answers (2)

user848765
user848765

Reputation:

As I know the ViewState property is a protected member of the Control class so it not accessible from other objects. If you just write "ViewState" in a Page declaration, it is actually the member of that Page object which in your case is disabled.

However you should be able to reach your user control's ViewState within your User Control.

See this explanation: http://msdn.microsoft.com/en-us/library/ms972976.aspx#viewstate_topic5

But anyway, this doesn't look like a good way of storing state information on a web page.

Upvotes: 1

Rob Hardy
Rob Hardy

Reputation: 1821

If you disable ViewState on the page, no rendered controls on that page will have ViewState information available.

If you want to disable ViewState just for some controls but not all, your best bet is ControlState as seen here.

Upvotes: 1

Related Questions