Reputation: 22556
I have a view in ASP.NET MVC4 and it has the following code which starts an HTML form:
@using (Html.BeginForm(new { ReturnUrl = ViewBag.ReturnUrl }))
Now i need to give this form an id="login" and a class="loginform". How do I specify such HTML parameters to the Html.BeginForm class?
Also: where can I find an API or documentation on all the HTML helper functions which explains all of the parameters and the details?
Upvotes: 0
Views: 3345
Reputation: 1293
Try the following in code:
@using (Html.BeginForm(null, null, new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { id = "login", @class = "loginform" }))
See information here:
http://msdn.microsoft.com/en-us/library/system.web.mvc.html.formextensions.beginform(v=vs.108).aspx
Upvotes: 2
Reputation: 5723
Take a look at this page on msdn: http://msdn.microsoft.com/en-us/library/system.web.mvc.htmlhelper_members(v=vs..90).aspx. It lists controls generation methods in Extension Methods section. You can find information about creating form element with attributes here: http://msdn.microsoft.com/en-us/library/dd492714(v=vs.90).aspx and here: How can I add a class attribute to an HTML element generated by MVC's HTML Helpers?.
Upvotes: 2