Beginform with several button in one form

Asked

Viewed 35 times

0

I have form that has several Buttons, 1 to delete via aja, 1 to edit via ajax, 1 to open report and I have 1 button for when it is clicked I wish to do the post form, the button of the post works the problem is that all others is also called the post method.

@using (Html.BeginForm("Create", "Home", FormMethod.Post, new { id ="submitForm" }))
{ 
 <button type="submit" id="btnSave" name="command" value="Save">Save</button>
 <button type="submit" id="btnSubmit" name="command" value="Cancel"/>
}

1 answer

0


This is because you set their type to Submit change to button, for those you don’t want to do Submit for form and control their behavior via javascript.

<button type="button" id="btnSubmit" name="command" value="Cancel"/>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.