mercredi 5 août 2015

Getting the value of a view property in the template


Using MVC and Nhibernate i am getting the property

x => CurrentRecord.Reference

This line is in the view itself but the view html is being rendered by a template. In the template i need to specify that if the value being rendered in the HTML is a number then align to the right and if the value is text then align left.

At the moment the html is using the below:

@{
 var propName = this.ViewData.TemplateInfo.HtmlFieldPrefix;
}
  <input class="form-control input-sm align right" data-bind="value: @propName" required />

This allows me to bind the element properly using jQuery but doesn't actually get me the value of the property.

How would i get the value of the property from the view model?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire