0

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?

Sabuncu
  • 5,095
  • 5
  • 55
  • 89
Zapnologica
  • 22,170
  • 44
  • 158
  • 253

2 Answers2

2

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?.

Community
  • 1
  • 1
Lukasz M
  • 5,635
  • 2
  • 22
  • 29
2

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

Charlie
  • 1,265
  • 15
  • 18