Manikandan LJ

Manikandan LJ

  • NA
  • 45
  • 1.5k

Controls with in dynamicaly loaded user control update panel

Dec 12 2018 10:35 AM
Hi,
 
I am loading the user control dynamically by the use of update panel when user select the tab . User control contains a button as 'btnCreate'. When i am binding the asyncpostback trigger to the parent update panel. It is throwing error. It is not at all calling button click event.
 
Button click event is not getting register with update panel. Can any one do some help on this? Thanks in advance 
 
Parent Page :
 
  1. <asp:UpdatePanel ID="updatePanelSearch" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional" RenderMode="Block">  
  2.         <ContentTemplate>  
  3.             <div class="row">  
  4.                 <ul class="nav nav-tabs tabs-center">  
  5.                     <li role="presentation" class="active"><a href="javascript:;" id="tabAdvancedSearch" data-child-id="tabContentAdvancedSearch" runat="server" onserverclick="tabAdvancedSearch_ServerClick">Advance Search</a></li>  
  6.                     <li role="presentation"><a href="javascript:;" id="tabSavedSearch" runat="server" data-child-id="tabContentSavedSearch" onserverclick="tabSavedSearch_ServerClick">Saved Searches</a></li>  
  7.                 </ul>  
  8.             </div>  
  9.             <div id="tabContentAdvancedSearch" class="row tab-content">  
  10.                 <asp:PlaceHolder ID="placeHolderAdvanceSearch" runat="server"></asp:PlaceHolder>  
  11.             </div>  
  12.             <div id="tabContentSavedSearch" class="row tab-content">  
  13.                 <asp:PlaceHolder ID="placeHolderSavedSearch" runat="server"></asp:PlaceHolder>  
  14.             </div>  
  15.         </ContentTemplate>          
  16.         <Triggers>  
  17.             <asp:AsyncPostBackTrigger ControlID="tabSavedSearch" />  
  18.             <asp:AsyncPostBackTrigger ControlID="tabAdvancedSearch" />  
  19.         </Triggers>  
  20.     </asp:UpdatePanel>  
  
User Control : 
  1. <div class="saved-search-container">  
  2.     <div class="row">          
  3.         <input id="btnCreateSearch" runat="server" class="btn btn-primary pull-right" onserverclick="btnCreateSearch_ServerClick"   
  4.             value="Add" type="button" />                     
  5.     </div>  
Parent page code behind:
 
 
  1. protected void tabSavedSearch_ServerClick(object sender, EventArgs e)  
  2.         {  
  3. placeHolderSavedSearch.Controls.Add(LoadControl("~/Shared/SavedSearch.ascx"));  
  4. ScriptManager currPageScriptManager = ScriptManager.GetCurrent(thisas ScriptManager;  
  5.             if (currPageScriptManager != null)  
  6.             {  
  7.                 currPageScriptManager.RegisterAsyncPostBackControl(control);  
  8.                 updatePanelSearch.Update();  
  9.             }  
  10. }  
 
User control code behind : 
 
  1. protected void btnCreateSearch_ServerClick(object sender, EventArgs e)  
  2.         {  
  3.             CreateSearch(sender);  
  4.         }