c# - ASP.NET MVC 3, how should I assign attributes with HtmlHelper.BeginForm? -


I have HTML attributes in the form created with ASP.NET MVC3 with the Html.BeginForm I want to assign, but it seems that I have to use surcharge

  BeginForm (this HtmlHelper html helper, string action name, string controller name, formmath method, object HTML attributes)   

It is enforcing this way:

  Html.BeginForm (empty, blank, FormMethod.Post, new {id = "my-form"}) < / Code>  

h The easiest way to do this, so I'll be sad new {id = "my-form"} as Html.BeginForm ?

There is some easy way to do this, so I can cross the new { Id = "my-form"} Html.BeginForm's only argument?

No, unless you write your own HTML support:

  public static class form extension {public static MvcForm MyBeginForm (This HtmlHelper htmlHelper, Object HTML Attitudes) {html html.backform (empty, blank, formMethod.Post, html content); }}   

and then:

  @using (HTML.MyBeginForm (new {id = "my-form"}) {...}   

Unfortunately you can not use the name BeginForm because there is already a parameter in which the parameter represents route value .

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -