0

When I click on button I need to invoke ResetValues method in controller. But am able to invoke the DocDetails method. Can anyone help me out!!

@using (Html.BeginForm("DocDetails", "FormAdmin", FormMethod.Get))
{
//some other controls and logic related to that
 @{ Html.BeginForm("ResetValues", "FormAdmin", FormMethod.Post);}


                        <button onclick="location.href='@Url.Action("ResetValues","FormAdmin")'" >Search2</button>

                      @{ Html.EndForm();}

}
user3477335
  • 165
  • 1
  • 2
  • 12

1 Answers1

0

Do not embed one form inside another.

Instead, you can use @Html.ActionLink() to create a link that redirects the user to a different action, then style the link to look like a button:

[Edited to show usage without nesting forms]

@using (Html.BeginForm("DocDetails", "FormAdmin", FormMethod.Get)) {

  //some other controls and logic related to that
  @Html.ActionLink("Search2", "ResetValues", new {},  new { @class = "button" })
}
Community
  • 1
  • 1
Peter Gluck
  • 8,168
  • 1
  • 38
  • 37
  • I have tried but no luck. Error message: http 404. Page not found. – user3477335 Jun 02 '14 at 18:20
  • Please try it without nested forms. The link renders to an HTML anchor element, so it can be placed anywhere on the page, even outside the form. If you are getting 404 error then the route to the action or the action parameters may be incorrect. You can add action parameters in the third argument. Does your action require a parameter? – Peter Gluck Jun 02 '14 at 18:46