Showing posts with label perform. Show all posts
Showing posts with label perform. Show all posts

Wednesday, March 21, 2012

Delete confirmation in GridView and Ajax

Hi, I'm performing an upgrade from a traditional asp.net 2.0 web site to asp.net ajax.

I could perform all the necessary upgrades in my application to work with ajax, but one: how can I ask the user (using a ok/cancel dialog) if he/she wants to delete some gridview row? (assuming I use a traditional "delete command column" in the grid)

1. I tried to set this up using triggers... but could not find a way to halt execution with a custom script an resume execution if users says "ok"

2. I tried to build a custom extender... but all I could do is "intercept clicks" on the gridview, not "when it happens in a delete command" (everywhere I click on the grid fires the popup)

if someone could point any resource I can look at or any clue...

thanks a lot,

Victor

here is the code

Protected Sub gv_Project_RowDataBound(ByVal senderAs Object,ByVal eAs GridViewRowEventArgs)Handles gv_Project.RowDataBoundIf e.Row.RowType = DataControlRowType.DataRowThen Dim lAs LinkButton =CType(e.Row.Cells(5).Controls(0), LinkButton)' 5 is your column count of delete column l.Attributes.Add("onclick","javascript:return " & "confirm('Are you sure you want to delete this record " & DataBinder.Eval(e.Row.DataItem, "Project_Name").ToString() & "')")End If End Sub
 
 
cheers 

thanks a lot!!!

this is really a much simpler task as I was wondering...

thanks again,

regards

Victor


Hello,

Thanks for this tip.

I have a GridView with both Deleting and Editing enabled.

My Code sets the e.Row.Cells index to 0 so that refers to the Gridview Command column.
Dim lAs LinkButton =CType(e.Row.Cells(1).Controls(0), LinkButton)

In this case the Confirmation if triggered on a click of Edit and not Delete.

I would appreciate and suggestion how to attach the confirmation to the "Delete" Link in the GridView Command Column.

Thanks Lex


Hello, I have solved this issue by creating 2 command buttons, one for the Edit and One for the Delete.

This then allowed the reference to the Link Button to index the Delete Cell or Column.

Thanks Lex


Thanks, working perfectly

Declarative Postbacks in Beta 2

Hello,

I had a small script function to perform a declarative postback. This worked in the July CTP, and we are in the process of upgrading to Beta 2. It is erroring out on not being able to locate the Sys.WebForms.PostBackAction type. Has this been removed/moved? If so, could someone point me in the direction of where it is hiding?

function postbackFromJS(sender, e) {
var postBack = new Sys.WebForms.PostBackAction();
postBack.set_target(sender);
postBack.set_eventArgument(e);
postBack.performAction();
}

Thanks!

I looked around the PageRequestManager class and couldn't find much so it looks like it was removed, though not sure if it was renamed. The docs are lacking in this area.

Anyways, here's the class you can take a look around:http://ajax.asp.net/docs/ClientReference/Sys.WebForms/PageRequestManagerClass/default.aspx


hello.

the postbackaction is defined on the preview.js file (ie, in the value-added bits).