Hide a div element and it's contents using c#

This can be a nice little trick to do if you want to hide options on a user after an update or after so many products are selected, etc. Simply wrap the area you want to hide in a div element and put a runat="server" value into it's tag. Example:

 

<div id="GridDiv" runat="server">
gridview would go in here....
</div>

 

You can now easily set the div to hidden using a bit of CSS that can be set using C# whenever your condition is met. For example:

GridDiv.Attributes["style"] = "display:none;";
//OR you could just type
GridDiv.visible = false;

That's all there is to it but you can see how powerful this can be as it allows you to dynamically set the css class or styles you might want in your applications.

C#
blog comments powered by Disqus

Get In Touch

Follow me online at TwitterFacebook or Flickr.

Latest Tweets