Our code should now handle a delete. The next step is to change the HTML to pass in the ID. The ID must be passed in the <form> postback. This is triggered by a submit button in an <a> tag. A hidden <input> tag can be used to store the ID in the browser until the user clicks Delete and does the <form> postback.

One new Bootstrap trick:

  • btn btn-danger btn-sm - make a small red button



In Pages/Continents/Index.cshtml, change the <div> surrounding the Details and Edit buttons to a <form>. Add the attribute method="post".


Add an <input> of type "submit" under the Edit <a> tag.

  • The value attribute should equal "Delete"
  • Its classes should be btn, btn-danger, and btn-sm.

The btn-danger class is Bootstrap CSS for the color red.


Next add a hidden <input> that can return the ID back to the server during the post.

  • The type should be "hidden"
  • The name should be "ID"
  • The value should be set to the current Continent item’s ID

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?