Reputation: 317
i am bit confuse in the syntax used in mvc. please tell me what is difference between these two syntax written below :
<%= Html.LabelFor(model=> model.studFatherName) %>
and
<%: Html.LabelFor(model=> model.studFatherName) %>
Upvotes: 0
Views: 297
Reputation: 1038730
<%: %>
is used to HTML encode the value whereas <%= %>
output the value as is. For example:
<%= "<br/>" %>
is rendered as <br/>
whereas <%: %>
is rendered as <br/>
. There is one exception though. If the argument is an IHtmlString
then <%: %>
behaves exactly the same as <%= %>
i.e. it doesn't encode the value. And since the LabelFor
helper returns an IHtmlString <%: Html.LabelFor(x => x.studFatherName) %>
is absolutely equivalent to <%= Html.LabelFor(x => x.studFatherName) %>
.
Upvotes: 2