.NET wants to control my Visibility!

May 31, 2007 at 4:16 pm Leave a comment

Ok, so I want to hide a control, label or block, I put it runat=”server” and on the server-side I simply do MyControl.Visible = false right? Well sure, that will simply not render the whole block on the client-side. What if you then want to make the visibility back up? You need to do a full postback, yikes!

Another option is to use MyControl.Style and change the visibility client-side, something like this:

<asp:Label ID="MyLabel" runat="server">Whatever. Bla Bla Bla...</asp:Label>

On the server-side code, we then do this instead: 

MyLabel.Style["display"] = "none";

And on the client-side, we can toggle it back to visible like this: 

document.getElementById('<%= MyLabel.ClientID %>').style.display='block';

Entry filed under: .NET, C#, Dev, Javascript, Programming, Technology.

Server-side escapes in AJAX using JSON Using Fiddler as a “Dev” Debugging Tool

Leave a comment

Trackback this post  |  Subscribe to the comments via RSS Feed


Calendar

May 2007
M T W T F S S
 123456
78910111213
14151617181920
21222324252627
28293031  

Most Recent Posts