0

Whatever I am doing, when i have two buttons in a form, even if one of them is CLEARLY not a submit button and the other one is submit type input, always both of them submit the form. I have piece of code like this:

       <form method="POST">
            <tr class="record">
                /* This one submits */
                <td><button onclick="location.href='editStudent.cshtml?id=@row.No'">Edit record</button></td>

                /* And so does this one */
                <td><input type="submit" value="Delete" /></td>
                </tr>
           </form>

I know i should not be creating a form mid-table, but this is not the point. Please, tell me what am i doing wrong, as i have been fighting this problem for way too long.

Ginterhauser
  • 196
  • 1
  • 2
  • 13

1 Answers1

0

As you can see here http://www.w3schools.com/tags/tag_button.asp you should define the type attribute of your button element in order to avoid unexpected behaviour

So if you do not want to mess with javascript you can try this <button type="button" onclick="location.href='editStudent.cshtml?id=@row.No'">Edit record</button>

montexristos
  • 290
  • 2
  • 5