C# – Custom Control loads a user control; Postback events are not triggered

asp.netcpostback

I have a custom control (compiled as a DLL) which loads a user control. (i.e, the custom control does a LoadControl) In the user control is a button and a textbox. I wire up the button's click event.

I type in a value into the text box. When I click the button, the page does a postback. My user control knows that a postback occured because Page.IsPostBack = true. However, the click event of the button is never fired and my text box has also lost the value that I typed in.

Anyone have any thoughts as to what might be going on?

EDIT:
I did a test on this and took SharePoint out of the picture; I was able to reproduce it so I removed all references to SharePoint.

Best Answer

If you are dynamically loading the user control, you have to reload it on each page load (postback or not) in order for the .net processor to know where to wire up the submit event.

Related Topic