0

Here, I want to pass name attributes to the Form. But this is passing name as query string: Following is the code I have used:

@using (Html.BeginForm("Upload", "AjaxUpload", new { @name = "form1" })) {

I have also remove @ at name it works as query string. WOuld you please tell how to pass name attributes like below:

<form name = "form1" action = "..">
CodeManiac
  • 974
  • 8
  • 34
  • 56

1 Answers1

0

You have used a wrong overload of BeginForm and it treats the new { @name = "form1" } as the route values collection.

You need to use a different overload which allows you to pass html attributes like this one:

@using (Html.BeginForm(
              "Upload", //action name
              "AjaxUpload", // controller name
              FormMethod.Post, // form method
              new { name = "form1" }) // htmlAttributes
       ){

}
nemesv
  • 138,284
  • 16
  • 416
  • 359