Solved

How to get the visibilty attribute value of a panel in javascript

Posted on 2011-02-11
4
413 Views
Last Modified: 2012-08-13
How to get the visibilty attribute value of a panel in javascript ?
0
Comment
Question by:PeteEngineer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 8

Assisted Solution

by:kivan24
kivan24 earned 150 total points
ID: 34869576
<div style="display:block;" id="mypanel">PENEL</div>
<script  type="text/javascript">
var panelvis = document.getElementById('mypanel').style.display;
alert(panelvis);
</script>

Open in new window

0
 
LVL 40

Assisted Solution

by:gurvinder372
gurvinder372 earned 50 total points
ID: 34869691
0
 
LVL 14

Accepted Solution

by:
dejaanbu earned 200 total points
ID: 34870851
if you r trying to get visiblility property then,

<script  type="text/javascript">
var panelvis = document.getElementById('<% =thePanel.ClientID  %>').style.visibility;
alert(panelvis);
</script>

if display property then replace style.visible with style.display
0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 100 total points
ID: 34871331
if the Panel is not visible .net don't generate/render the HTML so the object and its content is not in the page
So to know if the Panel is rendered or not, we may use :

 
           var Panel1 = document.getElementById("<%= Panel1.ClientID %>");
            var isVisible = (Panel1 != null); // true if visible, false else...

Open in new window

Or with jQuery :

           var isVisible = $("#<%= Panel1.ClientID %>").is(":visible");

Open in new window

           

Test page :

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <script language="javascript" type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
    <script language="javascript" type="text/javascript">
        $(document).ready(function() {
            //simple Javascript :
            var Panel1 = document.getElementById("<%= Panel1.ClientID %>");
            var isVisible = (Panel1 != null);
            alert(isVisible);
            // jQuery :
            isVisible = $("#<%= Panel1.ClientID %>").is(":visible");
            alert( isVisible );
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:Panel runat="server" ID="Panel1" Visible="true"></asp:Panel>
    </div>
    </form>
</body>
</html>

Open in new window

0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question