<% if (condition) { %>
<%= variable %>
<% } %>
or
<% if (condition) {
Response.write(variable);
} %>
<% if (condition) { %>
<%= variable %>
<% } %>
or
<% if (condition) {
Response.write(variable);
} %>
The one that you consistently use though the rest of your codebase.
I try to avoid both approaches you listed. But use a small wrapper method instead.
protected string DisplayVariable()
{
// conditionals, etc. go in here
....
}
Then call...
<%= DisplayVariable() %>
Some other alternatives you could have considered would be ...
<%: condition ? variable : "" %>
or create an Extension method on HtmlHelper that takes a condition and a string.
<%=Html.OptionalMessage(condition,variable) %>
Of your two supplied options, the second would be best because it is less to edit and easier to read.
However, I would urge you to also consider ideas from the other answers here; put as much code as possible into methods so you can have a really short call in the web page. This makes your web page logic much easier to read, especially for larger logic blocks and when there are more such blocks in one page.