Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to find control in Update Panel for trigger

In our application of asp.net with c#, we are using Ajax with update panel control. In panel, we have put export to excel button inside tab panel.

We have also put triggers after ending of content template. Please find below code for your reference.

<asp:UpdatePanel ID="UpdatePanelPage" runat="server" UpdateMode="Conditional">
    <ContentTemplate>

        <table id="tblMain" runat="server" cellpadding="0" cellspacing="0"    width="100%">
             <tr>
                 <td>
                     <asp:TabContainer ID="TabContainer1" runat="server" Width="100%">
                         <asp:TabPanel ID="tabCompanyName" runat="server">
          <asp:Button ID="btnStateExportToExcel" runat="server" Text="Export To Excel"    CssClass="button" OnClick="btnStateExportToExcel_Click" />
   </asp:TabPanel>
</asp:TabContainer>
                  </td>
            </tr>
        </table>
    </ContentTemplate>
   <Triggers>
          <asp:PostBackTrigger ControlID="btnStateExportToExcel" />
     </Triggers>
            </asp:UpdatePanel>

Now when we run the page following error would be display. “A control with ID 'btnStateExportToExcel' could not be found for the trigger in UpdatePanel 'UpdatePanelPage'.“ Any idea/suggestion would be highly appreciable.

*As per search results of Google, the button resides in tab panel due to which page was not able to find this control.

like image 363
Richa Avatar asked May 31 '13 05:05

Richa


1 Answers

Your button are located inside other controls. You should specify namingcontainer hierarchy for update panel trigger. I think this helps you:

<asp:PostBackTrigger ControlID="TabContainer1$tabCompanyName$btnStateExportToExcel" />
like image 55
Boriss Pavlovs Avatar answered Nov 22 '22 15:11

Boriss Pavlovs