Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1012119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T09:53:50+00:00 2026-05-16T09:53:50+00:00

I have a table with records that has delete links. Basically I followed the

  • 0

I have a table with records that has delete links. Basically I followed the NerdDinner tutorial for that part in MVC. But I don’t want to have the confirm view, I’d rather have a confirm dialog, and then if confirmed let the HttPost action method delete the record directly.

I have something working, but being new to both MVC and jQuery, I’m not sure if I’m doing it right.

Here’s the jQuery:

    $(function () {
        $('.delete').click(function () {
            var answer = confirm('Do you want to delete this record?');
            if (answer) {
                $.post(this.href, function () {
                    window.location.reload(); //Callback
                });
                return false;
            }
            return false;
        });
    });

And the delete actionlink:

<%: Html.ActionLink("Delete", "Delete", new { id = user.UserID }, new { @class = "delete" })%>

And finally, the delete action method:

    [HttpPost]
    public ActionResult Delete(int id)
    {
        _db = new UsersEntities();
        try
        {
            //First delete the dependency relationship:
            DeleteUserVisits(id);
            //Then delete the user object itself:
            DeleteUser(id);
        }
        catch (Exception)
        {
            return View("NotFound");
        }

        return RedirectToAction("Index");
    }

Now, I have a few questions about this:

  1. I found the function for making the link POST instead of GET on the internet: `$.post(this.href); return false; And I’m not sure what the “return false” part does. I tried to modify it for my needs with a callback and so on, and kept the return part without knowing what it’s for.

  2. Secondly, the action method has the HttpPost attribute, but I have also read somewhere that you can use a delete verb. Should you? And what about the RedirectToAction? The purpose of that was originally to refresh the page, but that didn’t work, so I added the window.location.reload instead in a callback in the jQuery. Any thoughts?

  3. The Delete action method calls a couple of helper methods because it seems with the Entity Framework that I use for data, I can’t just delete an record if it has relationship dependencies. I had to first delete the relationships and then the “User” record itself. That works fine, but I would have thought it would be possible to just delete a record and all the relationships would be automatically deleted…?

  4. I know you’re not supposed to just delete with links directly because crawlers etc could accidentally be deleting records. But with the jQuery, are there any security issues with this? Crawlers couldn’t do that when there is a jQuery check in between, right?

Any clarifications would be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T09:53:51+00:00Added an answer on May 16, 2026 at 9:53 am
    1. The return false statement serves
      the same purpose as
      e.preventDefault() in this case.
      By returning false JavaScript is preventing
      the browser from executing the link’s
      default click handler.

    2. The DELETE verb is for RESTful web
      services, it is most likely not what
      you want in this situation because
      not all browsers fully implement it.
      Read more about them here: Creating
      a RESTful Web Service Using ASP.Net
      MVC

    3. The deletion rules for child
      entities depend on the entity
      OnDelete/OnUpdate rules in the
      context definition and also on
      foreign key constraints in the
      database. You can learn more about
      foreign key constraints here
      .

    4. A crawler will not be able to
      activate your delete link in this
      fashion because you have specified
      the delete action be issued via a
      POST. If the delete were a GET then
      it would be a concern. Still, it’s
      not wise to keep links that directly
      modify your content on front-facing
      pages that do not require
      authentication as a human could most
      certainly exploit the process.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table that has 8 million records, with many fields, including lat/long
I have a table that has about 1/2 million records in it. Each month
I have a HTML table that displays rows of records and has a column
I have a table that has a processed_timestamp column -- if a record has
I have a table that records a sequence of actions with a field that
I have the classical table with expandable and collapsible records that if expanded show
I have a MySQL table holding lots of records that i want to give
Say you have a ServiceCall database table that records down all the service calls
I Have a table called Table1 which has 48 records. Out of which only
Hi all I have an appointments table that has among other fields a DATE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.