Asp.Net MVC2 Clientside Validation and duplicate ID's problem

给你一囗甜甜゛ 提交于 2019-12-04 19:31:11

For some controls you can specify the HTML attributes in an overload like this:

<%: Html.TextBoxFor(model => model.EmailAddress, new { id = 'my-unique-id" }) %>
<br />
<%: Html.ValidationMessageFor(model => model.EmailAddress, new { id = 'my-unique-id" }) %>

You can also either write your HTML by hand or use the older HTML helpers so you can add your own ID that way (you need to do this for Html.LabelFor() helpers)

<%: Html.TextBox( "EmailAddress", Model.EmailAddress, new { id = 'my-unique-id" } ) %>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!