Posts
1150
Comments
891
Trackbacks
1
I’d almost forgotten how much I love ViewState

Working on a project that uses WebForms for the first time in what seems like a couple of decades.  I know I could merge MVC views into it, but for various reasons that isn’t an option.

The great thing about WebForms (and I mean that entirely sarcastically of course) is when you try to do something that appears to be even slightly outside the normal happy path, you run into the issue where the black box magic stops working so magically and you have to go muck around.  I believe the percentage of projects that end up going slightly outside the normal happy path is approximately 100%, but I digress.

So, I have a datalist.  I add custom user controls to it dynamically.  I want to persist the information of each user control to viewstate, obviously.  I use the magic Page.RegisterRequiresControlState(this) in the user control override saving and loading control state as required.  When adding these user controls to a panel, it all works magically.  Because you have to databind a source to a datalist, it appears to blow view state for the controls away.

No doubt it is because I forgot the proper place to blah blah blah the view state in the pipeline.  Like I want to remember any of that.

Of course, if an asp.net panel had a repeatlayout and repeatdirection, I wouldn’t have to worry about it, as that’s the only reason I’m using a datalist in the first place.

Whhhhheeeeeee!!!!!!!!!!!!

posted on Wednesday, July 11, 2012 10:13 AM Print
Comments
No comments posted yet.

Post Comment

Title *
Name *
Email
Url
Comment *  
Please add 8 and 4 and type the answer here: