Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Button is not working with Update Panel

I have placed a timer and a label for displaying countdown time in an update panel. I have placed the next button for displaying the next question outside the update panel.

My problem is that the button click is not working with the update panel. Without using the update panel and the timer it works well. How can I solve the problem?

I have also tried to place whole tools inside the update panel. It didn't help me.

Here is my code:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
  <ContentTemplate>
    <table class="style1">
        <tr>
            <td class="style2">
                <asp:Timer ID="Timer1" runat="server" Interval="1000" ontick="Timer1_Tick">
                </asp:Timer>
                <asp:Label ID="lblTimer" runat="server"></asp:Label>
        </tr>
        <tr>
            <td style="margin-left: 40px" class="style3">
                <asp:Label ID="lblQuestion" runat="server"></asp:Label>
            </td>
        </tr>
        </table>
         </ContentTemplate>
                 </asp:UpdatePanel>
        <table>
        <tr>
            <td style="margin-left: 40px" class="style2">
                <asp:RadioButtonList ID="rblOptions" runat="server">
                </asp:RadioButtonList>
            </td>
        </tr>
        <tr>
            <td style="margin-left: 40px" class="style2">
                <table class="style1">
                    <tr>
                        <td class="style2">
                            <asp:Button ID="btnNext" runat="server" onclick="btnNext_Click" Text="Next"
                                    Width="75px" />
                        </td>
                        <td>

                            <asp:Button ID="btnFinish" runat="server" onclick="btnFinish_Click"
                                Text="Finish" Width="75px" />
                        </td>
                    </tr>
                    <tr>
                        <td class="style2">
                            &nbsp;</td>
                        <td>
                         <asp:Label ID="lblScore" runat="server">Score : </asp:Label>
                       </td>
                   </tr>
                </table>
            </td>
        </tr>
    </table>
<asp:UpdatePanel>

I added the following code.

<Triggers>
 <asp:AsyncPostBackTrigger ControlID="btnNext" EventName="Click"/>
</Triggers>

Still it didn't work. Could you please help me....

The selection of radio button is automatically cleared when using update panel. Any help....?

Thank you....

like image 764
james raygan Avatar asked May 21 '13 08:05

james raygan


1 Answers

Your UpdatePanel is malformed. You have one extra asp:UpdatePanel tag in the markup.

Use this instead:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <table class="style1">
            <tr>
                <td class="style2">
                    <asp:Timer ID="Timer1" runat="server" Interval="1000" ontick="Timer1_Tick">
                    </asp:Timer>
                    <asp:Label ID="lblTimer" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="margin-left: 40px" class="style3">
                    <asp:Label ID="lblQuestion" runat="server"></asp:Label>
                </td>
            </tr>
        </table>
        <table>
            <tr>
                <td style="margin-left: 40px" class="style2">
                    <asp:RadioButtonList ID="rblOptions" runat="server">
                    </asp:RadioButtonList>
                </td>
            </tr>
            <tr>
                <td style="margin-left: 40px" class="style2">
                    <table class="style1">
                        <tr>
                            <td class="style2">
                                <asp:Button ID="btnNext" runat="server" onclick="btnNext_Click" Text="Next" Width="75px" />
                            </td>
                            <td>
                                <asp:Button ID="btnFinish" runat="server" onclick="btnFinish_Click" Text="Finish" Width="75px" />
                            </td>
                        </tr>
                        <tr>
                            <td class="style2">
                                 &nbsp;</td>
                            <td>
                                <asp:Label ID="lblScore" runat="server">Score : </asp:Label>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </ContentTemplate>
<asp:UpdatePanel>
like image 7
bastos.sergio Avatar answered Nov 14 '22 05:11

bastos.sergio