Document.Ready() is not working after PostBack

This will be a problem with partial postback. The DOM isn’t reloaded and so the document ready function won’t be hit again. You need to assign a partial postback handler in JavaScript like so… function doSomething() { //whatever you want to do on partial postback } Sys.WebForms.PageRequestManager.getInstance().add_endRequest(doSomething); The above call to add_endRequest should be placed … Read more

How do I raise an event in a usercontrol and catch it in mainpage?

Check out Event Bubbling — http://msdn.microsoft.com/en-us/library/aa719644%28vs.71%29.aspx Example: User Control public event EventHandler StatusUpdated; private void FunctionThatRaisesEvent() { //Null check makes sure the main page is attached to the event if (this.StatusUpdated != null) this.StatusUpdated(this, new EventArgs()); } Main Page/Form public void MyApp() { //USERCONTROL = your control with the StatusUpdated event this.USERCONTROL.StatusUpdated += new EventHandler(MyEventHandlerFunction_StatusUpdated); … Read more

Abstract UserControl inheritance in Visual Studio designer

What we want First, let’s define the final class and the base abstract class. public class MyControl : AbstractControl … public abstract class AbstractControl : UserControl // Also works for Form … Now all we need is a Description provider. public class AbstractControlDescriptionProvider<TAbstract, TBase> : TypeDescriptionProvider { public AbstractControlDescriptionProvider() : base(TypeDescriptor.GetProvider(typeof(TAbstract))) { } public override … Read more