Hello -
I’m new to AJAX and going through an example in a book. It’s a very simple exercise which I was hoping to evolve into something real-world.
Problem is my panel know as pnlConfirmation is not being displayed once the timer runs out. When I click the button and fire the event, the UpdateProgress panel does show as expected but once it’s done, pnlConfirmation is not displayed.
I was hoping for a second set of eyes to point of the obvious error. Thanks!!
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Panel ID="pnlForm" runat="server"> <br /><br /> <asp:Button ID="Button1" runat="server" Text="Do something awesome" OnClick="Button1_Click" /> </asp:Panel> </ContentTemplate> </asp:UpdatePanel> <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1"> <ProgressTemplate> <asp:Panel ID="pnlProgress" runat="server"> <br /><br /> Doing something awesome now..... <br /><br /> </asp:Panel> </ProgressTemplate> </asp:UpdateProgress> <asp:Panel ID="pnlConfirmation" runat="server" Visible="False"> <br /><br /> Something awesome was done. <br /><br /> </asp:Panel>
…and…the button’s click event (C#):
protected void Button1_Click(object sender, EventArgs e) { pnlConfirmation.Visible = true; pnlForm.Visible = false; System.Threading.Thread.Sleep(5000); }
What am I doing wrong?
The panel needs to be inside the updatepanel contenttemplate.
Thanks but that didn’t seem to make a difference. Like this?
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Panel ID="pnlForm" runat="server"> <br /><br /> <asp:Button ID="Button1" runat="server" Text="Do something awesome" OnClick="Button1_Click" /> </asp:Panel> <asp:Panel ID="Panel1" runat="server" Visible="False"> <br /><br /> Something awesome was done. <br /><br /> </asp:Panel> </ContentTemplate> </asp:UpdatePanel> <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1"> <ProgressTemplate> <asp:Panel ID="pnlProgress" runat="server"> <br /><br /> Doing something awesome now..... <br /><br /> </asp:Panel> </ProgressTemplate> </asp:UpdateProgress>
You now have Panel1; this was pnlConfirmation.
<facepalm />
Thanks!