Conditionally excluding a block of html in ASP.NET WebForms

  ASP.NET Snippets

Some people object to the following method but its one that no one has answered with and I feel that it should be shown as an option. It can be handy when used properly.

<%if(ShowLabel){%>
<label>This will not be shown if the ShowLabel property evaluates false</label><%}%>

To make this work you would have a public or protected property on your page called ShowLabel which returns a boolean.

269 thoughts on - Conditionally excluding a block of html in ASP.NET WebForms

LEAVE A COMMENT