Consider, for example, that you are working with. Now the listing page might be showing only the partial information. If a user deletes an order without reviewing the complete. It would be desirable that he is presented with the. In such cases the first way of confirming. The. second technique may also be required in situations where you wish to use a minimum. Creating a Sample Application. Close A Window Asp Network' title='Close A Window Asp Network' />In order to illustrate both of the techniques discussed above, you will. ASP. NET MVC application. To begin with, create an empty. ASP. NET MVC application using ASPX view engine. The sample application will use. Employees table from the Northwind database and you will need to create an. Entity Framework data model for the same. News View All Win Development Resources The new VB. Web services and SOA implementations in the. NET Framework OData provides patterns for HTTP, JSON, data access. MSDN Magazine Issues and Downloads. Read the magazine online, download a formatted digital version of each issue, or grab sample code and apps. So, add a new ADO. NET Entity Data. Model in the Models folder and then drag and drop the Employees table on it. Doing so will create a model as shown below Figure 1 Add a new ADO. NET Entity Data Model. Confirming Deletes Without Leaving the Current Page. Once the data model is ready add a new controller class and name it Home. Add an action method Index as shown below public Action. Result Index. Northwind. Entities dbnew Northwind. Entities. var data from item in db. Employees. select item. View. Bag. Employees data. View. As you can see, the Index action method fetches all of the employees and. View. Bag property Employees. Then right click on. Index action method and add a view named Index. The Index view will. The. Index view as shown in the browser looks like this Figure 2 Index View of Employee Listing. The HTML markup of Index view is shown below lt h. Employee Listinglt h. Html. Begin. Form. View. Bag. Employees. Employee. ID lt td. First. Name lt td. Last. Name lt td. Html. Action. LinkDelete, Delete, new employeeid item. Employee. ID, new classdelete, iditem. Employee. ID lt td. As you can see, the view essentially renders a table and displays First. Name. and Last. Name columns. It also renders a hyperlink to initiate the delete. Notice that ID attribute of the hyperlink is set to Employee. ID so. that you can detect the employee ID to be deleted later in the code. Also, the. hyperlink is assigned a CSS class named delete. This is done so that your. Next, add an action method Delete. AJAX that deletes a specified. Http. Post. public Json. Result Delete. AJAXint employeeid. Northwind. Entities db new Northwind. Entities. Employee data from item in db. Employees. where item. Employee. ID employeeid. Single. Or. Default. Employees. Delete. Objectdata. db. Save. Changes. return JsonRecord deleted successfully. The Delete. AJAX action method is intended to be called from client side j. Query code and hence. Json. Result. Inside, it deletes an employee record based on. Employee. ID passed to it and returns a string message to the caller. In this technique you will be using j. Query to call the Delete. AJAX action. method. So, add a script reference to j. Query library. lt script src. Scriptsjquery 1. Then add a script block and write the following code in it lt script typetextjavascript. On. Delete. Click. On. Delete. Clicke. Id e. target. id. You are about to delete Employee ID employee. Id permanently. Are you sure you want to delete this record. Delete. AJAX. type POST. Id. data. Type json. Id. parent. parent. Error. return false. The ready function wires click the event handler of the delete hyperlinks. On. Delete. Click function. Notice how the delete hyperlinks are filtered. The On. Delete. Click function. ID of the delete link being clicked, using the target. It then seeks confirmation from the user using the confirm. Java. Script function. If the user clicks on OK, an AJAX call is made to the. Delete. AJAX action method using j. Query. ajax. Notice how the options of. Download Adventure Quest World Hack Trainer 2011 Movies there. The url parameter indicates the URL of the action. POST for. calling the action method. The data parameter is the JSON representation of the. ID to be deleted. Recollect that employeeid is the parameter name of. Delete. AJAX action method. When the remote action method completes. In the above example, the success function simply displays the message as. Delete. AJAX method. The concerned table row is then removed. This way the deleted record will be removed from the. Notice the use of the parent method. Since the delete hyperlink is. Now, run the index view and try deleting a record. The following figure. Figure 3 The index view after a delete attempt. Confirming Deletes by Navigating to a Confirmation Page. In the second technique of confirming deletes you will display an. In order to implement. Home. controller. Action. Result Confirm. Deleteint employeeid. Northwind. Entities dbnew Northwind. Entities. var data from item in db. Employees. where item. Employee. ID employeeid. Employee employee data. Single. Or. Default. Viewemployee. public Action. Result Deleteint employeeid. Northwind. Entities db new Northwind. Entities. Employee datafrom item in db. Employees. where item. Employee. ID employeeid. Single. Or. Default. Employees. Delete. Objectdata. db. Save. Changes. return View. In the previous example you called the Delete. AJAX method directly from the. In this case the delete operation will not happen from the. When a user clicks on the delete link, he will be taken. Confirm. Delete view wherein delete confirmation is sought. On the delete. confirmation page you will display details such as Employee. ID, First. Name. Last. Name and Notes so that the user can review the record being deleted. The. Confirm. Delete action method essentially retrieves an employees information. Confirm. Delete view. The Confirm. Delete view then calls the. Delete action method if the user decides to delete that record. The Delete. action method simply deletes an employee record from the database. After completing the Confirm. Delete and Delete action methods, right. While creating the. Confirm. Delete view make sure to create a strongly typed view based on Employee. Figure 4 Confirm. Delete. The following figure and HTML markup shows what the Confirm. Delete view looks. Figure 5 Confirm. Delete View. lt using Html. Begin. FormDelete, Home, Form. Method. Post. lt h. Warninglt h. 2. You are about to delete the following Employee record. Model. Employee. ID. Model. First. Name Model. Last. Name. lt Model. Notes. lt strong. Are you sure you want to delete this record Html. Hidden. Form m. Employee. ID. Delete. lt input typebutton valueCancel onclickOn. Cancel. Click. As you can see, the Confirm.