What different are there between Visible="false" and display:none;

I use both Visible="false" and display:none to hide panel, could you tell me what diffrent there are? such as speed,  performance, website size..

Thanks!


<%@ 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></title>
    <style type="text/css">
        .myHide
        {
           display:none;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Panel ID="Panel1" runat="server" Visible="false">
        a1
        </asp:Panel>
       
        <asp:Panel ID="Panel2" runat="server" CssClass="myHide">
        a2
        </asp:Panel>
    </div>
    </form>

</body>
</html>


SuperCool Multiple ZIP - A utility to unzip multiple files and work with multiple zip files

SuperCool Random Number Generator
0
mycwcgr
4/20/2009 12:56:14 PM
asp.net.web-dev-2005-express 3977 articles. 0 followers. Follow

7 Replies
711 Views

Similar Articles

[PageSpeed] 3
Get it on Google Play
Get it on Apple App Store

I think the important difference lies in whether you need access to the items inside the panels, client-side.  Setting visible=false will cause the panel not to be rendered, so you can't get at any of the controls, once again, client-side.  Whereas if you set display none, then you will have access to the controls, as the panel is rendered.


C# <---> VB.Net Translator
0
MetalAsp
4/20/2009 1:05:48 PM

 Simplified, the hidden panel No. 2 will be rendered but just not shown up (client-side), unlike the Panel1 that will not be rendered at all (server-side).


When you ask a question, remember to click "Mark As Answer" when you get a reply which answers your question.
0
Kulrom
4/20/2009 1:06:20 PM

 when you set visible="false" the client code for the panel does not get sent to the client, when you use display:none the equivelent code is sent to the client browser but it's display is hidden by css. try view source on the result of the above code you pasted. you should see a hidden div on the source for panel2, but for panel1 there should be no html code at all


Web Hosting Compare
0
icecape67
4/20/2009 1:06:49 PM

Well, display: none entirely removes the element from the page, and the flow of the page is calculated as though the element were not there at all. On the other hand, visibility: hidden leaves the space in the document flow even though you can no longer see the element. Depending on what you are doing, that can make a huge difference or be no big deal. any way go through this....  http://www.maconstateit.net/tutorials/ASPNET20/ASPNET04/aspnet04-02.aspx


Chinna_sv...
0
getchinna_sv
4/20/2009 1:18:34 PM

Hi,

 

The main difference is that the Visible is offered as part of the Control base class and the display property is made to be accessible from CSS.  Now if you set a server control to Visible = False it will not be rendered when IIS serves the page to the client, on the other hand if you set the panel's display style property to none the panel will indeed be render on the page markup (as a div....all asp.net panel controls are rendered as a  div element) but will not be visible.

You realize this by looking at the html source code when the page is rendered. 

So the only performance hit will be when rendering the page that it will need to render and generate extra html tags if the display property is set to none.

 

And as you might have guessed in regards to performance, speed, etc that will depend on how many children elements this panel will have....by setting the panel's visibility you are actually setting its children's visibility as well since the panel control is a container control.

 

Hope it helps.

 

Leo. 

0
leonelpc
4/20/2009 1:22:00 PM

Thanks!

Does it mean Visible="False"have less page size and more quickly speed if Panel1 and Panel2 have the same child controls?


SuperCool Multiple ZIP - A utility to unzip multiple files and work with multiple zip files

SuperCool Random Number Generator
0
mycwcgr
4/20/2009 1:49:04 PM

mycwcgr:

Thanks!

Does it mean Visible="False"have less page size and more quickly speed?

Yes since that part of HTML is not rendered hence you page Size will be less and in case of display none it will be rendered

Note if you are accessing your panel using client sidr scripting like javascript then you should use display none


MAKMark as Answer if this reply helps you
MVP ASP/ASP.Net
MVP ASP/ASP.Net
ASP.Net Hosting : Host DepotMy Site : ASPSnippets
0
mudassarkhan
4/20/2009 1:55:48 PM
Reply:

Similar Artilces:

Difference between "Visual Studio 2005 Professional" and "Visual Web Developer 2005 Express Edition"
I would like to build a web application for my department.  But I found that both tools can be used to build a ASP web site.  What is the difference between these two tools ?  Do they function the same ?  You can review this online features matrix between all visual studio versionshttp://msdn2.microsoft.com/en-us/vstudio/aa700921.aspx  Hosam Kamel Remember to click on Mark as answer on the post that helped you Have a look here http://blogs.msdn.com/mikhailarkhipov/archive/2006/06/26/647516.aspx. Thanks----------------------------------------------------------...

Upgrading from "Visual Web Developer 2005 Express Edition Beta 2" to "Visual Studio 2005 Beta 2"
Newby question: I am learning ASP.NET and downloaded "Visual Web Developer 2005 Express Edition Beta 2" in order to practice and learn the ropes.I just received "Visual Studio 2005 Beta 2" and would like to upgrade. However, I haven't found any reference to removing "Visual Web Developer 2005 Express Edition Beta 2" before installing "Visual Studio 2005 Beta 2".Should I remove it?What do I need to back up before doing so?Thanks in advance,Ira I believe you can install VS on top of VWD. They, in fact, can coexits (although they will share some files).Thanks----------------------------------...

What is this for? "<label style=""display:none;"" for=""" & cboFieldType.ClientID.ToString & """>Type</label>"
I'm digging through the code of DNN and I found many ocurrences of this type of code: lblFieldType.Text = "<label style=""display:none;"" for=""" & cboFieldType.ClientID.ToString & """>Type</label>" What is that code for? The label is never displayed and I could not figure out what DDN uses it for. thank you This is for ADA compliance. The guidelines require that form elements have an associated label. This helps the text readers out with identifying the different parts of the form. BruceDynamic...

Regular Expression to remove "/", "\", "<", ">" and "="
Can anyone please show me the regular expression to reject a string ("<blue", "right>" etc.) which has the following expression in it: "/", "\", "<", ">" and "="  hi, It may Help u.. it is in Class file u may use this expressin in validation controls also. Regex objReg = new Regex(@"^[^,.?/\~|`;:'<>]*$", RegexOptions.Singleline); Regex objReg = new Regex(@"^[^,][^.][^?][^/][^\][^~|][^`][^;][^:][^'][[^<][^>]$", RegexOptions.IgnoreCase);Thanks &...

VS.NET 2005 is ignoring in web.config strict="true". I get no error when I try this: Dim x As Integer = "string"
Hello,I have this in my VS.NET 2005 web.config <compilation debug="true" strict="true" explicit="true">When I do this in my vb code:Dim x As Integer = "string"I get no error. When I hit compilation I also get no error. What am I doing wrong?Thanks for helping!Regards,J. Bauer It's a bug of some sort See this response by Scott Guthriehttp://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=3c1c9898-8076-4f69-a5e2-e99573d03c6e Unfortunately we don’t have a GUI based way to configure this. L It is something we will make sure gets added back in, though, with the next...

wrong character display ("�" displays as "�" or "?")
Using ODBC Sybase 11 router, the character "�", saved in a varchar column in Sybase 11.5 will display as "�" or "?" in SQL Advantage or in our application. This just started occuring once we changed our applications to use 32 bit ODBC connection, rather than DBLib 16 bit. What is really interesting is that our our old 16 bit application runnning on the same PC returns the characters correctly, while 32 bit application running against ODBC returns another character, usually the degree symbol. Both versions of this program are accessing the same data sou...

difference between "using System.Web.UI.WebControls" or "System.Web.UI.WebControls.ServerValidateEventArgs"
Hi all, quick question. I'm writing a custom validation method. In the declaration it has: protected void CustomValidator1_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args) Is there any difference between doing that, vs doing: using System.Web.UI.WebControls; protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args) Do they do the same thing? Is it any more efficient when processing the request to do it one way or another? Is there a technical term for what i am talking about? Thanks in advance for any explanation ...

what is the difference between "Application" and "Session" when you develop a web program?
 can somebody tell me what the differnce between "Application" and "Session"? when we are developing a web program?I know the Session meaing... what about Application? thanks Data stored in the Application is accessible for all users of your app while each user would get their own unique Session. Give this wiki article a read: http://wiki.asp.net/page.aspx/30/state-management/Mike Banavige~~~~~~~~~~~~Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/ Hi Friend, Here is two difference between Session an...

Difference between customErrors mode="On" and "RemoteOnly" in web.config
I am debugging some asp.net code written using .NET 1.0./VS 2003. I noticed that in the web.config filethey use the customErrors attribute to redirect to an error page if an error occurs. This is done bysetting the custom error attribute to "RemoteOnl" Here is the code. <customErrors mode="RemoteOnly" defaultRedirect="error/PropAvailError.aspx"/> I was wondering. What is the difference between setting the custom errors mode to "RemoteOnly" as opposed to "On". What is the difference between the two? Hello, here is a link to the doc ...

What is the difference between "for " and "foreach"
I always confused when should I use "for" and when foreach should be used...when we talking about efficient which one is better to use?thank you  its quite the same just a different way howto, never done or read about big differences about the both options:  string [] n = new string[] {"test1", "test2"} foreach(string a in n)   .... for(int i=0;i< i<n.Length;++i)   ....regards, roni---speed up your applications with distributed caching or replicated caching: http://www.sharedcache.com - its free! thank you , How about efficien...

Visual Studio "Orcas" Visual Studio.net "2005"
What are Microsoft on weed??? Whidby Orcas Indigo XAML Longhorn What are they trying to do to us developers. The transition to any new tools should be minimal. What we know about WebServices is now old bunk. Why did we bother with .net 1.1???????? Now we need to learn new silly names and new ways of doing things. Yes .net 1.1 is still supported in v2.0. But there are a million and one other needless things that we will have pushed onto us. Only to find in anther two years that they are old hat and there are new radical ways to do what we want.MCAD.Net vb.n...

Table visible=False? (tblTable2) &quot;visible=false&quot;???
When the Default.aspx archive will be lowered of the server as I make to below occult this (tblTabela2) in this code: (hide tblTabela2) visible=false? code of the file below:<%@ Page Language="VB" %> <script runat="server"> Sub cmdEnviar_Click(sender As Object, e As EventArgs) tblTabela.visible=false cmdEnviar.visible=false txtSeuNome.visible=false lblTexto.visible=false lblFrase.text="Olá "& txtSeuNome.Text &" seja bem vindo a...

Could you tell me what different between "logo{..." , ".logo{..." and "#logo{..."
Could you tell me what different between "logo{..." , ".logo{..." and "#logo{..." logo {  position: absolute;  left: 15px;  top: 15px;  z-index: 100;} .logo {  position: absolute;  left: 15px;  top: 15px;  z-index: 100;} #logo {  position: absolute;  left: 15px;  top: 15px;  z-index: 100;}SuperCool Multiple ZIP - A utility to unzip multiple files and work with multiple zip filesSuperCool Random Number Generator This may help: logo {  position: absolute;  left: 15px;  top: 15px; ...

different between kernel "Trace","pae" and "default"
I want to know the differences among them. When I instlled opensuse, it uses pae as kernel. After I run "install software", it prompts me to restart system to enable new kernel. When I choose "default kernel" not "pae kernel", it can not display X-windows GUI but only text mode. But if I choose "trace kernel", I can log on X-window like "pae kernel". I couldn't find any differences between them. -- nAthrun ------------------------------------------------------------------------ nAthrun wrote: > > I wan...

Web resources about - What different are there between Visible="false" and display:none; - asp.net.web-dev-2005-express

Resources last updated: 12/11/2015 5:45:38 AM