How can I name a form using Html.BeginForm ()?

How do I specify a form name in ASP.NET MVC using Html.BeginForm() ? I want only the name, not the name of the action or controller , because I want to publish it through Javascript. I think it should be something like Html.BeginForm(id = "frm") .

I tried the following:

 Html.BeginForm(null,null,new{id="frm",name="frm}) Html.BeginForm(new{@id="frm",@name="frm}) 

But the above code produces the output as follows:

 <form action="/Main/Index/Id?name=Id" method="post"> 
+68
asp.net-mvc razor
Sep 10 '10 at 9:03
source share
4 answers
 Html.BeginForm(null, null, FormMethod.Get, new { name = "frm", id = "frm" }) 

You need to catch the submit form using your JavaScript

+110
Sep 10 '10 at 9:10
source share

Using MVC2, this is what worked for me:

 <% using (Html.BeginForm("Index", "Home", null, FormMethod.Post, new {@id = "myForm", @name = "myForm"})) {%> 
+7
Mar 10 '12 at 1:00
source share
 @HTML.BeginForm("Target-ViewName where you want to post the page","Controller Name",new {@name="Name of the Form", id="ID of the Form"}) { //form here } 
+1
May 24 '12 at 17:15
source share

Taken from this answer: How to pass an identifier using Html.BeginForm ()?

Can't you just:

 Html.BeginForm(new {@id="Id", @name="Id"}); 

He can pay for looking for SO for answers, since I found many things that I want to ask, have already met.

-3
Sep 10 '10 at 9:11
source share



All Articles