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

  • Home
  • SEARCH
  • 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 7218549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T21:29:50+00:00 2026-05-28T21:29:50+00:00

I have done create,edit functionality & trying to do delete functionality but by default

  • 0

I have done create,edit functionality & trying to do delete functionality but by default my page redirects to the Delete.aspx for delete confirmation.
I want the following steps to occur when i try to delete my record. Currently i am on
index.aspx and want to stay on same page & delete the record from database.

Image 1
enter image description here

Image 2

enter image description here

Image 3

enter image description here

I don’t want this deletion from URL.
for ex. http://localhost:53402/Project/Delete/11, it will be very easy for anyone to delete any record giving id.

  • 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-28T21:29:51+00:00Added an answer on May 28, 2026 at 9:29 pm

    in order to perform a delete using javascript and a pop-up, you need to:
    1)Create an action in the controller like the following:

    [HttpPost]
    public void DeleteItem(int id)
    

    By decorating the action method with the [HttpPost] annotation, you avoid the undesired behaviour of a user typing the URL /Home/Delete/1 because only a POST will invoke the action.

    2)If you delete-item is part of a list of items, you need to bind to your items in the View a sort of id, using the custom HTML5 attributes, like the following:

    @for (int i = 0; i < Model.Items.Count; i++)
    {                            
         <a href="#" class="delete-button" data-id="@Model.Items[i].Id">Delete</a>        
    }
    

    3)Using jQuery, as an example, bind to your delete button(s) in the page a pop-up on click

    $().ready(function () {
        $(".delete-button").click(null, DeleteItem);  //DeleteItem is the callback      
        return false;
    });
    

    We need to specify a callback that will handle the delete button click

    4)Using for example jQuery UI dialog component:

    Create HTML for your pop-up text

    <div id="dialog-confirm" style="display:none;" title="Confirm">
    <p>
        <span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>
        Are you sure you want to proceed?
    </p>
    </div> 
    

    Handle the delete button click and bind the dialog to the html text so that the popup will tell the user what you want

    function confirmDeleteVersion() {        
        var recordToDelete = $(this).attr("data-id"); // now we need the data-id to retrieve the identifier for the item to delete              
        $("#dialog-confirm").dialog({
            resizable: false,
            height: 200,
            modal: true,
            buttons: {
                "Delete": function () {         
                    $(this).dialog("close");        
                    $.post("/Home/Delete", { id : recordToDelete}, DeleteSuccessfull);
                },
                Cancel: function () {
                    $(this).dialog("close");
                }
            }             
        });     
    };
    

    So, we get the id of the button

    var recordToDelete = $(this).attr("data-id");
    

    where “this” is the HTML element which caused the event to fire using

    The below row is actually where we ask the Controller to execute the delete action, and we use the id of the record

    $.post("/Home/Delete", { id : recordToDelete}, DeleteSuccessfull);
    

    5) Because the jQuery post is asynchrounous, we need a callback to handle the result

    function DeleteSuccessfull()
    {
        //Do what you want...
    };
    

    That’s it… keep in mind that it’s just an example and I’m using jQuery dialog component, while you could use something different.

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

Sidebar

Related Questions

my goals (this is for training purpose): User can create(50%DONE)/edit/delete/view a created Quiz! The
I have done the following form <% form_for @anexo, :url => {:action => create},
I need to create a Firebird Database programmatically using DBExpress. I have done this
I have done Java and JSP programming in the past, but I am new
I have done a little Django development, but it has all been in a
I have done jQuery and Ajax, but I am not able to get the
I am trying to create thread safe properties in C# and I want to
I have done a bit of testing on this myself (During the server side
I have done a bit of research into this and it seems that the
I have done some searches looking for information about how to do logging with

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.