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'
LVL 3
Abdu_AllahAsked:
Who is Participating?
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.