c# - Why does this not display the display name? -


i'm trying display displaynames properties in html in asp.net mvc 4 application. though i've set displaynames in viewmodel raw variable names still gets displayed instead.

the viewmodel:

public class manage_managepasswordviewmodel {     [display(name="name")]     public string name;     [display(name = "subid")]     public string subid;     [display(name = "conversions")]     public int conversions;     [display(name = "password")]     public string password;     public userprofile owner;      public manage_managepasswordviewmodel(protectedpassword pw)     {         name = pw.name;         subid = pw.subid;         conversions = pw.getconversions();         password = pw.password;         owner = pw.owner;     } } 

the cshtml file:

@model areas.admin.models.viewmodels.manage_managepasswordviewmodel  <div class="editor-label">     @html.displaynamefor(m => m.name):     @html.displaytextfor(m => m.name) </div> <div class="editor-label">     @html.displaynamefor(m => m.password):     @html.displaytextfor(m => m.password) </div> <div class="editor-label">     @html.displaynamefor(m => m.subid):     @html.displaytextfor(m => m.subid) </div> <div class="editor-label">     @html.displaynamefor(m => m.conversions):     @html.displaytextfor(m => m.conversions) </div> <div class="editor-label">     @html.displaynamefor(m => m.owner.username):     @html.userlink(model.owner.username, model.owner.userid) </div> 

use properties instead of fields, ex.

[display(name="name")] public string name {get;set;} 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -