Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC 2 - Setting id of Html.Form

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

like image 553
Justin Avatar asked Jun 12 '10 17:06

Justin


1 Answers

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" }))
like image 53
Raj Kaimal Avatar answered Oct 23 '22 19:10

Raj Kaimal