Skip to content

Is ViewState forgetting something?

February 13, 2007

Sometimes when you develop an ASP.Net custom control you might get stumped as to why the values you input are not being persisted through postbacks. The problem usually is that you didn’t follow the “pattern” to correctly hook up with the ASP.Net page architecture.

View state recording starts once you add the control to the Controls collection. This is typically done in the CreateChildControls method. However, this method isn’t to be called directly by your code instead you call EnsureChildControls at some point in the page life cycle early enough to persist your viewstate. I find this works well enough:

protected override void OnLoad(EventArgs e)


From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: