I use the HTML Helpers to render my fields:
<%=Html.EditorFor(m => m.User.Surname)%>
and the output would be something like this:
<input class="text-box single-line" id="User_Surname"
name="User.Surname" type="text" value="" />
The helper uses the className + '.' è fieldName to build the id.
I need to pass the id to a jQuery function. Is there a way to have it without hardcoding it?
Maybe an helper which can use the ASP.NET MVC2 conventions?
ASP.NET MVC 4 has Html.IdFor() built in that can return this:
@Html.IdFor(m => m.User.Surname)