Hi all, We have developed a custom web control that implements ICallback Event Handler and fires an event when the callback is invoked.We had hoped that subscribers to this event would be able to update the state of other web controls but have been unable to make this work. However at first postback you either find the control is not loaded or the viewstate is not preserved for that control.Now when you click on submit button and you find that the control disappears. The reason is as we have loaded the control the page’s control tree does not have its detail so we need to load the control again with each postback.
The process is same however we don’t have to use Load Control method, we can directly use Controls.The viewstate requires the controls ID to store the viewstate properly. Once the control is added to the “ collection, it plays “catch-up” with the page life cycle, and all the events that it missed are fired.So always use code shown in Fig – (4) to load user control dynamically. This leads to a very important conclusion: you can add dynamic controls at any time during the page life cycle until the “ are fired for this control.The first parameter is the Update Panel you want to associate the script with.The second parameter is a type parameter, we’ll just use the type of the current object for this. The third parameter, “My Action”, is a key to identify the script, allowing you to reference or update it in the future if you wish. This can be a block of inline Java Script but I prefer to wrap everything I want to happen in a function and call that instead.To register a control as a postback control it is a 1 line DNN API call: Dot Net Nuke. That's it, no grabbing special references to the controls, no complex manual wrapping of your control in an Update Panel. Most of us have faced the case when we have to load the controls dynamically. When user clicks on Load Control button we will load the user control and on Submit button we just submit the form so that postback occurs.A simple google search for "AJAX Postback Control DNN" returns a number of creative solutions.Some of these instruct you to do a bunch of extra work that just isn't needed. Register Post Back Control(btn Run Report); In this case we are setting btn Run Report to cause a postback. Provided you have defined the function do My Action() somewhere everything should work as you expect.In an effort to get more regular content out here to the blog I am going to try and resume my "Quick Tips" posts.