When the page initially renders, the initializeControl function is called and everything works.
When the page performs a full post-back (via a submit button), the initializeControl function is also called and everything works.
When there is partial post-back of the UpdatePanel, though, the initializeControl function is never called and the control stops working.
HTML:
<asp:ScriptManager ID="myScriptManager" runat="server" />
<asp:UpdatePanel ID="myUpdatePanel" runat="server">
<ContentTemplate>
<uc:MyControl ID="myControl" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
User Control:
Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
Dim initializeScript = String.Format("initializeControl('{0}');", ClientID)
Page.ClientScript.RegisterStartupScript(GetType(Page),
New Guid().ToString(), initializeScript, True)
MyBase.Render(writer)
End Sub
For testing purposes, assume the initializeControl function is just a debugger; (the content of the function works fine - it's just not being called when it needs to be).
Please keep in mind that there is no way (that I know of) for the user control to know if it is inside an UpdatePanel or not, and there is also no way it can access the ScriptManager element on the parent page in server code.
Thanks in advance.
P.S. I know UpdatePanels are awful and should be avoided at all costs, but I am working with hundreds of consuming pages that are already using them and they can not be changed.