locked
A control with id could not be found for trigger in update panel RRS feed

  • Question

  • User-163012697 posted

    Hello ,

    I am posting the accordion pane in update panel , and in that pane there are some of the buttons but, i am getting the error when i use the triggering for the button click event.

    Here is Source Code:

    <asp:UpdatePanel ID="UpdatePanelacc" runat="server" UpdateMode="Conditional">
    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="btnCal" />
    </Triggers>
    <ContentTemplate>
    <table width="100%">
    <tr>
    <td>
    <cc1:Accordion ID="Accordion1" runat="server" HeaderCssClass="headeraccordian">
    <Panes>
    <cc1:AccordionPane ID="AccordionPane1" runat="server">
    <Header>
    <asp:Label ID="dailyreport" runat="server" Text="Daily Report"></asp:Label>
    </Header>
    <Content>
    <div>
    <asp:TextBox ID="txtDate" runat="server" ReadOnly="True" Width="94px"></asp:TextBox>
    <asp:Button ID="btnCal" runat="server" Text="Select Date" OnClick="btnCal_Click" />
    &nbsp;
    <asp:Button ID="btnDownLoads" runat="server" Text="Download" OnClick="btnDownLoads_Click" />
    <asp:Calendar ID="cal" runat="server" OnSelectionChanged="cal_SelectionChanged" BackColor="White"
    BorderColor="White" BorderWidth="1px" Font-Names="Verdana" Font-Size="9pt" ForeColor="Black"
    Height="190px" NextPrevFormat="FullMonth" Width="350px">
    <SelectedDayStyle BackColor="#333399" ForeColor="White" />
    <TodayDayStyle BackColor="#CCCCCC" />
    <OtherMonthDayStyle ForeColor="#999999" />
    <NextPrevStyle Font-Bold="True" Font-Size="8pt" ForeColor="#333333" VerticalAlign="Bottom" />
    <DayHeaderStyle Font-Bold="True" Font-Size="8pt" />
    <TitleStyle BackColor="White" BorderColor="Black" BorderWidth="4px" Font-Bold="True"
    Font-Size="12pt" ForeColor="#333399" />
    </asp:Calendar>
    </div>
    </Content>
    </cc1:AccordionPane>

    </Panes>
    </cc1:Accordion>
    </td>
    </tr>
    </table>
    </ContentTemplate>
    </asp:UpdatePanel>

    Kindly provide me the solution for this.

    Wednesday, December 24, 2014 12:38 AM

Answers

  • User1918509225 posted

    Hi jjbhatt_asp,

    Because your control is in Accordion control and is out of scope to Trigger collection

    So it will throw the exception like below:

    A control with id could not be found for trigger in update panel.

    your button control is already in UpdatePanel,so you don't need toadd trigger

    because it will update when you click the button.

    You just need to add  UpdatePanelacc.Update() in btnCal_Click event.

    Best Regards,

    Kevin Shen.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 24, 2014 10:18 PM

All replies

  • User1577371250 posted
    <asp:UpdatePanel ID="UpdatePanelacc" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
    <table width="100%">
    <tr>
    <td>
    <cc1:Accordion ID="Accordion1" runat="server" HeaderCssClass="headeraccordian">
    <Panes>
    <cc1:AccordionPane ID="AccordionPane1" runat="server">
    <Header>
    <asp:Label ID="dailyreport" runat="server" Text="Daily Report"></asp:Label>
    </Header>
    <Content>
    <div>
    <asp:TextBox ID="txtDate" runat="server" ReadOnly="True" Width="94px"></asp:TextBox>
    <asp:Button ID="btnCal" runat="server" Text="Select Date" OnClick="btnCal_Click" />
    &nbsp;
    <asp:Button ID="btnDownLoads" runat="server" Text="Download" OnClick="btnDownLoads_Click" />
    <asp:Calendar ID="cal" runat="server" OnSelectionChanged="cal_SelectionChanged" BackColor="White"
    BorderColor="White" BorderWidth="1px" Font-Names="Verdana" Font-Size="9pt" ForeColor="Black"
    Height="190px" NextPrevFormat="FullMonth" Width="350px">
    <SelectedDayStyle BackColor="#333399" ForeColor="White" />
    <TodayDayStyle BackColor="#CCCCCC" />
    <OtherMonthDayStyle ForeColor="#999999" />
    <NextPrevStyle Font-Bold="True" Font-Size="8pt" ForeColor="#333333" VerticalAlign="Bottom" />
    <DayHeaderStyle Font-Bold="True" Font-Size="8pt" />
    <TitleStyle BackColor="White" BorderColor="Black" BorderWidth="4px" Font-Bold="True"
    Font-Size="12pt" ForeColor="#333399" />
    </asp:Calendar>
    </div>
    </Content>
    </cc1:AccordionPane>
    
    </Panes>
    </cc1:Accordion>
    </td>
    </tr>
    </table>
    </ContentTemplate>
    </asp:UpdatePanel>

    public void btnCal_Click(object sender, EventArgs e)
    {
    
      // do all your work
      UpdatePanelacc.Update();
    
    }

    Wednesday, December 24, 2014 9:56 AM
  • User1918509225 posted

    Hi jjbhatt_asp,

    Because your control is in Accordion control and is out of scope to Trigger collection

    So it will throw the exception like below:

    A control with id could not be found for trigger in update panel.

    your button control is already in UpdatePanel,so you don't need toadd trigger

    because it will update when you click the button.

    You just need to add  UpdatePanelacc.Update() in btnCal_Click event.

    Best Regards,

    Kevin Shen.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 24, 2014 10:18 PM