[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1286
  • Last Modified:

Make updatepanel control visible using javascript

Hi, I need to make make updatepanel control visible using javascript, I did something like the following but it does not work:
1 Solution
If you have set the updatepanel to "UpdatePanel3.visible=false" then you cannot set it in lcient script to visible.  Instead of setting the updatepanel to "UpdatePanel3.visible=false" (ie. make sure "UpdatePanel3.visible=true")  set its style.display to "none" in javascript and then you can use javascript to make it visible.  The attached code shows a basic templatefor this.  Note that the return code for the "panelvisible" function is false as it will stop the form from posting when you click the button to show the panel.
<asp:UpdatePanel ID="updatepanel3" runat="server" UpdateMode="Conditional" Visible="true">
            <asp:Label ID="lblHello" runat="server">Hello</asp:Label>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <asp:Button ID="Button1" runat="server" Text="Show the update panel" OnClientClick="panelvisible()" />
    <script type="text/javascript">
        var e = document.getElementById("<%= updatepanel3.clientID %>");
        e.style.display = "none";
        function panelvisible() {
            e.style.display = "block";

Open in new window


Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now