Search code examples
asp.netplaceholder-control

ASP.Net Placeholder vs if directive


When working with markup if I want to include some content conditionally, I use a placeholder in a normal way:

<asp:Placeholder Visible=<%# IsExpired %>
  <span>Prolong your subscription</span>
</asp:PlaceHolder>

Also I can use if-directive:

<% if(IsExpired) {%>
  <span>Prolong your subscription</span>
<% }%>

I prefer using the first one just because it does not make my markup messy. And what's the best way to conditionally include content? From the performance point of view, are they similar?


Solution

  • native HTML tags are always faster than rendering server controls as there is no time spent for rendering them