Delete Link With Jquery Confirm In MVC 2 Application?
Aug 22, 2010
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:
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.
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?
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...?
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?
View 2 Replies
Similar Messages:
Dec 27, 2010
i am using jquery upload plugin- jquery.MultiFile.js in my project to upload multiple files in this file now i need a confirm button when delete file so i changed code
if(!MultiFile.trigger('onFileRemove', slave, MultiFile)) return false;
View 1 Replies
Dec 14, 2010
I have a Gridview (VS2008 3.5) which has a Edit Button and a Delete button.he Delete button deletes the row without confirming deletion with the user first. ow can I use the Confirm/Delete Confirm from Ajax Toolkitif possible and if not, is there a way to Confirm/Delete with user firstwhen using Gridview?
View 6 Replies
Nov 8, 2010
[Code]....
Implementing the listview control with delete link and lightbox?
View 1 Replies
Jan 31, 2013
I'm using ASP.NET 4.0. Having hard times figuring out how to get confirmation from user before deleting in a DetailsView. I'm using buttons.
I did google and found Javascript code to get confirmation OnClientClick event. But it displays 'Record Successfulley deleted' no matter what you choose. Here is the code-
HTML Code:
<ItemTemplate>
<asp:Button ID="Button1" runat="server" CausesValidation="False" SkinID="DefaultButton10pt"
CommandName="Edit" Text="Edit"></asp:Button> <asp:Button ID="Button3" runat="server"
CausesValidation="False" CommandName="Delete" OnClientClick="confirm('Are you certain you want to delete this
Record?');alert ('Record successfully deleted.');"
SkinID="DefaultButton10pt" Text="Delete" /> <asp:Button ID="Button2" runat="server"
CausesValidation="False" CommandName="New" Text="New">
</asp:Button> <asp:Button ID="Button4" runat="server" CommandName="Cancel" CausesValidation="False"
Text="Cancel"></asp:Button>
</ItemTemplate>
View 3 Replies
Sep 24, 2010
[Code]....
[Code]....
Compilation Error Description:
An error occurred during the compilation of a resource required to service
this request. Please review the following specific error details and modify your
source code appropriately. Compiler Error Message: CS0117:
'Northwind.tbl_zaposleniRow' does not contain a definition for
'Replace'Source Error:
[Code]....
Line 74: Northwind.tbl_zaposleniRow product = (Northwind.tbl_zaposleniRow)((System.Data.DataRowView)e.Row.DataItem).Row;
Line 75:
Line 76: db.OnClientClick = string.Format("return confirm('Are you certain you want to delete the {0} product?');", product.Replace("'", @"'"));
Line 77: }
Line 78: }
View 3 Replies
Nov 11, 2010
General Info:Aspx page holds an Ascx User control. Inside the User control, the Repeater is contained inside a View, contained inside a Multiview.
Asp.Net 2.0 framework / C#
Details:I have a repeater(inside an ascx user control) that shows records, and the first column is a checkbox. If checked, that row will be deleted.OUtside the repeater, I have a button that will deleted all rows that are checked.Everything works fine, but have been asked to add a pop up "confirm delete" message that includes the number of records that will be deleted if the user clicks "Ok" on the pop up.
Something like: "You are about to delete 8 records".
Currently my button looks like this:
<asp:Button ID="btnDeleteAllRecords" runat="server" Text="Delete all Checked Records" Onclick="btnDeleteAllRecords_Click" OnClientClick="javascript:GetCbCount();" />
I have this javascript code block:<script type="text/javascript">
function GetCbCount()
{
var cb = document.getElementById("rptrVoicemail").getElementsByTageName("input"); [code]....
View 2 Replies
Feb 3, 2010
Using "Enable Delete" from Gridview control, I can delete (besides, update, sort, paging, etc) data from the database (this is done automatically). However, how can I delete the actual image that resides in my image folder (i.e. from "pix" folder )? What is the best way to delete image? If using code behind, how? Please write a full code for me. Here is my source code.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="photoID"
View 12 Replies
Jun 8, 2010
How can I pop up a message box to confirm a delete, from inside a method?
Normally i would just use the following line in my button:
OnClientClick="return confirm('Are you sure you want to delete this comment?');"
However this delete method can also be called by a querystring, so I need the confirm message box functionality in the method?
[code]....
I can't click the button through code, because it doesn't fire the OnClientClick event btnDelete_Click(null, null);
View 3 Replies
Aug 17, 2010
I have been trying find a way, where whan a basic user wants to reset a record due to a typo. The use has to get a admin to enter there user password to confirm the update. this is based on a sql server 2008 DB that will execute a stored procedure to perfom the reset update. I am coding in c# working on a 3.5 framwork. I have seen thare a many confirm popup message box options but none for a password to confirm.
View 2 Replies
Dec 6, 2010
I use a gridview in my aspx page with a asp:CommandField for delete data.. I need a confirm for action, than I add:
Protected Sub lavorazioni_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles lavorazioni.RowDataBound
View 6 Replies
Oct 31, 2010
Is there any way of using ajax confirm button for dynamically created hyper link control?
I am using data in table and each row has dynamically created link control, so if the user click on the link then it will delete the row from database. Is there any way if i can use ajax confirm button for hyper link?
View 7 Replies
Feb 11, 2010
you can see the page under development at http://job1data.com:8098/admin.aspx
it looks like its setup right, the page source has the correct message for each button for the javascript:return invoked with onclick, all that was setup in the onItemDataBound routine and the delete code behind is getting invoked, i just have a message there for now for testing, so it all seems to be there, but no confirm dialog box?
View 7 Replies
Oct 18, 2010
i have an item template delte button inside DataGrid, and i would like to didplay a confirmation box , once user try to delete row..
below is my code:
[Code]....
View 1 Replies
Feb 2, 2011
I am trying to get a new line when display the message. Whats wrong with this code?
Button l = (Button)e.Row.FindControl("btnDelete");
string textForMessage = @"<script language='javascript'> confirm('Are you sure you want to delete this record
test
test
test');</script>";
l.Attributes.Add("onclick", textForMessage + DataBinder.Eval(e.Row.DataItem, "Name") + ")");
View 2 Replies
Jan 7, 2011
I want to prompt the user before allowing them to save a record. So let's assume I have the following button defined in the markup:
<asp:Button ID="btnSave" runat="server" OnClick="btnSave_Click"></asp:Button>
To force a prompt with normal javascript, I could wire the OnClick event for my save button to be something like this (I could do this in Page_Load):
btnSave.Attributes.Add("onclick",
"return confirm('are you sure you want to save?');");
The confirm call will block until the user actually presses on of the Yes/No buttons, which is the behavior I want. If the user presses 'Yes', then my btnSave_OnClick method would be called.
For the jquery dialog that is the equivalent, I tried something like this (see below). But the problem is that unlike javascript confirm(), it's going to get all the way through this function (displayYesNoAlert) and then proceed into my btnSave_OnClick method on the C# side. I need a way to make it "block", until the user presses the Yes or No button, and then return true or false so the btnSave_OnClick will be called or not called depending on the user's answer.
Currently, I just gave up and went with javascript's confirm, I just wondered if there was a way to do it.
[code]...
View 2 Replies
Mar 15, 2011
I want a similar behavior of "confirm delete" option in ASP.Net Gridview, as this questions shows How to add a "confirm delete" option in ASP.Net Gridview ? but using Jquery Confirm Box.
I'm having a lot of problem with postback behavior and asp.net page flow.
I want domething simple as:
<asp:Button ID="ButtonRemove" runat="server" Text="<%$ Resources:Localizacao, BUTTON_REMOVE %>" OnClick="ButtonRemove_Click" OnClientClick="displayConfirmDialog();/>
how I can fire the OnClick event in javascript, or how a can put a Panel as confirm dialog?
*today I use ajaxcontroltoolkit, but as this was discontinued I'm trying to figure out some more elegant alternative.
View 1 Replies
Jul 30, 2010
i am using jquery to implement a modal confirm windows but it not working i have a template field button with ajax confirm using jquery but i have a problem. Apper the confirm windows but when i click on "yes" doesn't execute the delete command. without ajax (using template field button and simple confirm windows javascript) works so well.
[Code]....
View 13 Replies
Sep 29, 2010
I have a Custom confirm box with Yes No.....The function executes in Jquery when click on Yes/No.But I want to exec my code there.....how it is to be done?This is code
//This is the file creating ConfirmBox
<script type="text/javascript" src="scripts/jquery.alerts.js"></script>
<script type="text/javascript" >
View 5 Replies
Jan 25, 2011
How to add a "confirm delete" option in ASP.Net Gridview ?
View 3 Replies
May 27, 2010
i am currently working on an asp.net mvc 2 web app and would like to add some ajax functionality on my delete item actions.Show, on the list items displayed view page, i wrapped the list items inside a partial view and added an ajax delete action link for each item (inside a foreach loop):
[Code]....
On the AjaxDeleteItem ajax controller action, i delete the selected item and redisplay the updated items list (via UpdateTargetId = "divList", where the list items partial view resides).My question is how i could insert Antiforgery token in such a scenario in order to secure delete operations from CSRF and XSRF attacks.
View 1 Replies
Dec 24, 2010
I have a link button in a repeater control. the li element is drag and droppable using jquery. when the page loads the the link button works perfectly, the jquery that is attached and the server side code both execute. when I perform a drag and drop then click on the link button it doesnt not fire. when i click it a second time it does fire. If i perform 2 or drag and drops in a row the link button doesnt fire a as many drag adn drops as i before it will fire. for example if if perform 3 drag and drops then it will take about 3 click before the events are fired.
[Code]....
View 4 Replies
Nov 10, 2010
<%: Html.ActionLink("Delete",
"Delete",
new { id=item.Emp_ID
})%>
how to add an image instead of first "Delete"
View 10 Replies
Apr 13, 2012
How can I display confirmation message -"are you sure to delete click yes or no button" on user click on delete link
<asp:ButtonColumn CommandName="Delete" HeaderText="Delete" Text="Delete" >
<ItemStyle BackColor=GhostWhite /> </asp:ButtonColumn>
How can I do it if java script how can use script here
View 1 Replies
Dec 13, 2010
Is there a way based on the current user that when the page loads that the Delete option on the gridview is disabled?
View 1 Replies