I have been using a variant of the Html.BeginForm() method to attach an html attribute to my form, like this :
@using (Html.BeginForm("actionname", "controllername", FormMethod.Post, new { id = "myform" }))
Unfortunately this causes the form target to loose all route data.
Say my url was controller/action?abc=123
, then using Html.BeginForm()
generates the form post target as controller/action?abc=123
but the overloaded version (which I am using to add the html id attribute to the form), generates the target as controller/action
(which actually is understandable, since I am specifying the route myself, but it doesn't solve my purpose).
Is there a variant of the Html.BeginForm()
which would allow me retain the old route values and let me add html attributes to the form at the same time?