ASP.NET MVC Model Binders, html id -


Using model binders in ASP.NET MVC 2.0, you can do something like this ...

< Pre> [DisplayName ("username")] public string name {get; Set; } & Lt;%: Html.TextBoxFor (m = & gt; m.Name):%>

And then in your HTML, you get a result like this ..

  & lt; Label = "username" & gt; Username & lt; / Label & gt; ; & Lt; Input type = "text" id = "user name" name = "username" />  

It works fine, but I have to have better control over HTML ID. Is there any way to do this model through a binding method?

You must override the editor template string to render the string editor. It basically involves creating a String.ascx partial view. You can find more detailed information in the "overriding template" section of the blog post.


Comments