n2009 n2009 - 1 year ago 73
ASP.NET (C#) Question

ASP.NET 2.0 HtmlTable Rows - hiding without making invisible

I need to find a way to hide HTML Rows (or Tables) from view without blocking them from being rendered. Setting this.myTable.Visible = false would seem to be the easiest way to hide tables from the user, but it prevents the HTML Table from being sent to the browser and that causes a problem because I am using Validators and need to make sure the non-visible elements are validated (because of page navigation logic, only some elements will be made visible to the user at a time).

I was attempting to change the Style property but asp.net says it is read-only so I cannot make it invisible using CSS. Also I would prefer not to use Javascript but if there is a simple solution with JS that is fine.

Any help is greatly appreciated.

Answer Source

To hide a complete table (but still render it to the client), wrap it in a div with style="display:none":

<div style="display:none;">
 asp.net table goes here

Although, for single rows, this does not work. You will probably have to use some javascript (e.g. jquery, as another user recommended).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download