Conditionally excluding a block of html in ASP.NET WebForms

Home » ASP.NET Snippets » Conditionally excluding a block of html in ASP.NET WebForms
ASP.NET Snippets No Comments

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.

LEAVE A COMMENT