accessing model object from view for MVC asp.net -
i have line of code within .aspx file
<label title="<%= model.productname %>"></label>
why when run it, label not showing @ all.
yet if work:
<%: html.labelfor(model => model.productname) %>
i first method work, there way?
thank you
it's because need provide contents label:
<label title="some title" for="productname"> <%: model.productname %> </label>
the way wrote markup <label>
tag empty. make sure html encode contents. notice in example usage of <%:
(available in asp.net 4) instead of <%=
. if running on previous versions use the following:
<label title="some title" for="productname"> <%= html.displayfor(x => x.productname) %> </label>
Comments
Post a Comment