asp.net mvc - Cannot assign attibutes to form using Html.BeginForm -
i have form begun html.beginform()
helper method:
@using (html.beginform( null,null, new { @id = "maintenanceform", @class = "datatable", @nonvalidate="nonvalidate" } ))
and form rendered as:
<form action="(controller's name)/(current action's name)/maintenanceform?class=datatable" method="post">
the attributes such id, class, , nonvalidate
aren't assigned. not want default http method. can do?
your current code matching below overload of beginform method
public static mvcform beginform( htmlhelper htmlhelper, string actionname, string controllername, object routevalues )
the third parameter here object route values. these added querystring key value(s) form's action
attribute value. reason seeing big url action attribute value.
if want specify html attributes( id,class etc), use overload has fourth parameter takes html attributes. third parameter formmethod.
public static mvcform beginform( htmlhelper htmlhelper, string actionname, string controllername, formmethod method, object htmlattributes )
this should work.
@using (html.beginform("create", "post",formmethod.post, new { @id = "maintenanceform", @class = "datatable", @nonvalidate = "nonvalidate" })) { }
replace create
, post
action method name , controller name.
Comments
Post a Comment