Wednesday, March 28, 2012

HOW DO I update a control from outside the updatepanel

i have an update panel with 4 panels. when the user select panel 2 i need a control outside the updatepanel to become visible. i can not put the hidden div inside the updatepanel because the contents of the div will not work. how do update the div control from panel 2?

To make visible the control outside updatepanel is not possible upto my knowledge. definitely you have to include that control into another udpatepanel or include it with your 1st updatepanel.


Hi CurlyFro,

Here is the sample to indicate how to show a hidden div, which is out of a UpdatePanel, from a panel click event or a button click event in UpdatePanel. Hope it helps.

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void Page_Load(object sender, EventArgs e) { } protected void Button2_Click(object sender, EventArgs e) { ScriptManager.RegisterStartupScript(this, this.GetType(), "key", "showDiv();", true); }</script><html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server"> <title>Untitled Page</title> <script language="javascript"> function showDiv(){ document.all.myDiv1.style.display=''; //do something here to update the hidden div } </script></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate><%=DateTime.Now.ToString()%> <asp:Panel ID="Panel1" runat="server" Height="50px" Width="200px" onclick="showDiv()" BorderColor="AliceBlue" BorderWidth="1px"> <input id="Button1" type="button" value="button" /> </asp:Panel> <br/> <asp:Panel ID="Panel2" runat="server" Height="50px" Width="200px" BorderColor="Black" BorderWidth="1px" > <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="ServerSideButton" /> </asp:Panel> </ContentTemplate> </asp:UpdatePanel> <div id="myDiv1" style="width: 200px; height: 100px; display: none"> This is the hidden div </div> </form></body></html>

This sample contains two ways (server side and client side methods) to show the hidden div.

If i misunderstood you, please let me know!


i'm creating a registration form. panel1 is my license, panel2 is the registration form, panel3 is my confirmation. on panel2 i have form hints for specific textboxes. how do i get the form hints to be hidden then shown on panel2?

Since you have many steps, I suggesting to wrap these in an Asp.net Wizard Control then put the Wizard Control in an UpdatePanel.


Hi CurlyFro,

Would you please share your source code here ? It is not necessary that you send out the complete source of your project. We just need a simplest sample to reproduce the problem. You can remove any confidential information or business logic from it.

Hi CurlyFro,

Has your problem been resolved yet?

No comments:

Post a Comment