0

I have a form and 2 submit buttons. The Yes button will display #modal1 and the No button will display #modal2. The form need to submit to controller. I refer this question in order to solve this. I am using this answer. It display the modal but the form are not submit

<input type="button" value="Create" onclick="location.href='@Url.Action("Create", "User")#modal1'" />

But the example shows only for type="button". Is there anyway I could do this using submit button?

<form Class="form-horizontal" role="form" method="get" id="myform">
    <input name="eventDate" id="eventDate" Class="form-control">
    <button type="submit" id="btnSearch1" value="search" class="btn btn-success">Yes</button>
    <button type="submit" id="btnSearch2" value="search" class="btn btn-success">No</button>
</form>
Community
  • 1
  • 1
hud.
  • 160
  • 1
  • 14

1 Answers1

0

You can try the formaction attribute to solve the issue.

@using (Html.BeginForm("#", "#", null, FormMethod.Post, new { }))
{
   //your form element goes here.....
   <button class="ui button" type="submit" formaction="@Url.Action("Register", "User")#modal1">Register</button>
   <button class="ui button" type="submit" formaction="@Url.Action("Login", "User")#modal2">Login</button>
}
TechVision
  • 269
  • 1
  • 11