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

x
  • 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:
document.getElementById(<%=UpdatePanel3.ClientID%>).style.visibility='visible'
0
Abdu_Allah
Asked:
Abdu_Allah
1 Solution
 
kssoftwareCommented:
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">
        <ContentTemplate>
            <asp:Label ID="lblHello" runat="server">Hello</asp:Label>
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:Button ID="Button1" runat="server" Text="Show the update panel" OnClientClick="panelvisible()" />
        </ContentTemplate>
    </asp:UpdatePanel>
 
    <script type="text/javascript">
        var e = document.getElementById("<%= updatepanel3.clientID %>");
        e.style.display = "none";
        
        function panelvisible() {
            e.style.display = "block";
        return(false)
        }
    
    </script>

Open in new window

0

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