c# - how to add an asterix for the LabelFor helper? -


i building mvc 4 app. have field called organisationid, mandatory.

@html.labelfor(m => m.organisationid) 

i need put asterix after label field required. how access labelfor templates? stored? how create own?

thanks

on model use data annotations

  [required]   [uihint("requiredtemplate")]//this trick should match file name.   [display(name="organization id")]   public string name { get; set; } 

drop new folder in views/shared/displaytemplates create new partial view requiredtemplate.cshtml.

<font style="color:red">*</font>@html.labelfor(m => m) 

in view organization should use displayfor

  <div class="display-field">      @html.displayfor(m => m.name)  </div> 

Comments

Popular posts from this blog

Change the color of an oval at click in Java AWT -

What can cause "Required Package 'IndyCore' not found" when compiling a Delphi 2010 project? -