ASP.NET Show Div Conditionally
asp.net, c#, webforms
Solution
<% if ( showDiv ) { %>
<div></div>
<% } %>
where showDiv would be a protected property in your code behind.
Problem
I have googled this and didn't find what I needed. All of the existing solutions I found say to set "visibility" to false. This will not seem to work for me as my application renders PDF which simply "hides" the DIV and leaves a big white space in it's place. Instead, I would like to not render the HTML at all. For instance, in PHP, this could be done as simply as: ``` <?php if ($showDiv == true) { ?> <div>Lorem ipsum dolor sit amet</div> <?php } ?> ``` In ASP.NET MVC, I could simply pass a ViewBag variable and do the same thing. What is the solution for this in ASP.NET (C#)?