Get LoadPostData to fire on Web Custom Control with ASP.NET 2.0 (C#)
I was trying to write my first web custom composite control and for the life of me, I couldn't get the LoadPostData event to fire. After wrestling with this for a day, I stumbled onto this site that laid it down step-by-step. After checking these things, it worked.
Here's the article for reference:
LoadPostData doesn't fire
I've struggled with this a couple of times, but I think I've got it figured out now. When I implement IPostBackDataHandler on my ASP.NET server control, my LoadPostData event doesn't get hit. This is because I haven't read the MSDN documentation properly.
For a ASP.NET server control to handle postback data correctly, it has to meet the following criteria.
1. The class must implement IPostBackDataHandler.
2. Implement LoadPostData to load the form data.
3. The name (not the ID!) of one of the html controls it renders must exactly match the UniqueID of the control (I always forget this one).
4. Implement RaisePostDataChangedEvent.
Not too tricky.

No comments:
Post a Comment