views:

50

answers:

1

Hey,

How do you set the id of an Html.Form in ASP.NET MVC 2?

I tried this:

<% using (Html.BeginForm("Save", "Clients", new { id = "SubmitForm" })) {%>

But it doesn't work, my form still doesn't have an id property:

<form action="/TothSolutions/Secure/Clients/Save/SubmitForm" method="post"> 

I'm guessing this worked in ASP.NET MVC 1 but not 2. The reason I need the id property set is so that I can do jQuery validation on the form: $("#myForm").validate etc...

Thanks, Justin

+2  A: 

You are using the wrong overload. Use this one:

http://msdn.microsoft.com/en-us/library/dd492714.aspx

using (Html.BeginForm("Save", "Clients", FormMethod.Post, 
                 new { id = "SubmitForm" }))
Raj Kaimal