Tom Hamming
Tom Hamming

Reputation: 10961

Do invisible controls and their children on an ASP.NET page contribute to viewstate?

I have an ASP.NET page that has about 40 custom controls embedded in it. The controls vary in size; in their .ascx files, the biggest is about 1,500 lines and the smaller ones are between 100 and 200 lines (markup, script, etc).

Each control is contained in a Panel. Only one of these panels is ever visible at any one time, which means only one control is ever visible at one time.

My question is this: do the controls that are invisible still send ViewState for themselves and all their children to the client? It makes sense that they might have to serialize the fact that they're invisible, but not all the state info for their children...

Upvotes: 2

Views: 191

Answers (1)

Pow-Ian
Pow-Ian

Reputation: 3635

If you wrote your controls yourself, and did not explicitly say that the items in the controls should not be added to the viewstate when the parent is not visible, then yes they should be in the view state.

Upvotes: 3

Related Questions