开发者

ASP.NET MVC Model Binders, html id

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开发者_StackOverflow中文版 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜