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

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -