1

I'm trying to build in form hinting for a web application. The form hints are stored in the "Description" attribute of my ViewModel.

public class ViewModel{
  [Description("Field description for input hints")]
  public string Name {get;set;}
}

I need to be able to pass these through to my form controls "data-content" field.

<input data-content="Field description for input hints" name="Name" class="guidance"/>

I'm unable to just use a simple EditorFor as I can't add additional HTML fields to it.

If I create an editor template, I'd obviously need to access the model metadata. I'm unsure how to do this if I'm passing a null model?

Ben Ford
  • 1,354
  • 2
  • 14
  • 35

2 Answers2

0

Is this what you are looking for? Sorry for the conformation in the form of answer due to shortage of rep.

In JQuery can you add Attributes like below

$('Some ID').attr('your attr', 'Some Val')
evevffv
  • 446
  • 1
  • 4
  • 14
0

you can use like this:

@Html.EditorFor(m => m.ColName, new { @class = "abc" })
Altaf Sami
  • 846
  • 5
  • 10
  • 21
  • You can't specify htmlAttributes like that when using EditorFor. see: http://stackoverflow.com/questions/3735400/html-attributes-for-editorfor-in-asp-net-mvc – Ben Ford Jun 10 '13 at 14:31