The button does not work with the update panel

I set a timer and a label to display the countdown time in the update panel. I placed the following button to display the next question outside of the update panel.

My problem is that clicking the button does not work with the update panel. Without using the update panel and timer, it works well. How can i solve the problem?

I also tried to put 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 have added the following code.

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

However, this did not work. Could you help me....

The selection of the switch is automatically cleared when using the update panel. Any help ....?

Thanks....

+7
source share
7 answers

If you use the main page, add this code to the page load event

 using AjaxControlToolkit; 

 ToolkitScriptManager objScriptManager = (ToolkitScriptManager)this.Master.FindControl("ScriptManager1"); objScriptManager.AsyncPostBackTimeout = 36000; 

..............

+2
source

Your UpdatePanel is incorrect. There is one additional asp tag in the markup : UpdatePanel .

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> 
+7
source

These seem to be inconsistent tags. Right and go through the layout again. Instead of using the AjaxToolkit library, start using jQuery navigation plugins, you can feel better.

+3
source

Add

 <Triggers> <asp:PostBackTrigger ControlID="btnNext" /> </Triggers> 

and add Ajaxtoolkit to your project ... then just provide the link below after <% @Page .........%>

 <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> 

also add the following code to your form tag.

  <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> 

This will solve your problem.

+2
source

You should put the button in the update panel, then it will work fine

  <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> <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> 
+2
source

You need to register the NEXT button to update the panel. for registration you need to use <asp:asyncpostbacktrigger xmlns:asp="#unknown"> inside UpdatePanel

i.e.

 <updatepanel> <contenttemplate> ... body ...... </contenttemplate> <triggers> <asp:asyncpostbacktrigger controlid="btnNext" eventname="Click" /> </triggers> <updatepanel></updatepanel></updatepanel> 
+1
source

If there is a validation error on the page (including hidden es errors: modal dialog). The event does not work. Tray for setting another button verification group (es: validationGroup = "xxx")

 <asp:Button ID="btnFinish" validationGroup="none" runat="server" onclick="btnFinish_Click" Text="Finish" /> 

I hope for this help.

0
source

All Articles