I have this line of code within my .aspx file
<label title="<%= Model.ProductName %>"></label>
why is it when I run it, the label is not showing at all.
yet if I do something like this it would work:
<%: Html.LabelFor(model => model.ProductName) %>
I would really like for the first method to work, is there a way?
thank you
It’s because you need to provide contents for this label:
The way you wrote your markup the
<label>tag is empty. Also make sure you properly HTML encode the contents. Notice in my example the usage of<%:(available only in ASP.NET 4) instead of<%=. If you are running on previous versions you could use the the following: