views:

37

answers:

1

Using the Model Binders in ASP.NET MVC 2.0, you can do something like this...

[DisplayName("User Name")]
public string Name
{
 get;
 set;
}

<%: Html.TextBoxFor( m => m.Name ) :%>

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

<label for="UserName">User Name</label>
<input type="text" id="UserName" name="UserName" />

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

+1  A: 

You need to override the editor template for a string to control how the editor for a string is rendered. This basically involves creating a String.ascx partial view. You can find more detailed information in the "Overriding Templates" section of this blog post.

s1mm0t