Delete confirmation box?

G

Grant

Im using a datagrid with the property builder to add a 'delete' button
column. Im binding a datareader to the datagrid at runtime and have got an
event handler which fires perfectly. The thing is I would like to add a
confirmation messagebox to to the delete button but I cant get it to work. I
found this sample:

-----------------
Response.Write("<script language='javascript'>window.alert('How're ya going,
mate?');</script>")

-----------------

but that adds to the ASP page, and the datagrid is bound at runtime in code,
so Im not sure how to link the two...

anyone know how I can get some sort of message prompt to confirm the delete?
Im using C# in a web application.


Thanks,
Grant
 
G

Grant

How do I assign an attribute to each delete linbutton in that column? The
delete column was created in the ide using the property builder and the only
reference to that delete button is this event handler:
'this.AllResultsDataGrid.DeleteCommand' - I cant see where else I can add
that attribute.

Do I need to loop through the controls or columns collection for that
datagrid, and add an attribute to the delete command if its found?

Thanks,
Grant
 
G

Grant

That site was useful thanks for that. The example uses the
'DataGridItemEventArgs' and the code I have passes
'DataGridCommandEventArgs'. Anyway I managed to get it to this point:

e.Item.Attributes.Add("onClick", "return confirm('Are you sure you wish to
delete this item?')");

But when i click the link - it looks like it adds the attributte first time
(with no prompt) then only on the second click it pops up asking for
confirmation.

why aint it firing first time?

Thanks,
Grant
 
G

Grant

Ahh, thank you that works nicely on my local machine. Copied the modified
aspx.cs to the web server (restarted IIS just to be sure) but the prompt
doesnt appear - it just sits there like before waiting for something.
Do you know if theres anything else i should do?
 
G

Grant

Your right, I recompiled and replaced everything on the server and it works
perfectly! Thanks for your help. There is no ways I would have known about
adding that to the attribute of the linkbutton - I still dont know exactly
how it works, but it does and Ill find out why when everythings working.

Thanks again,
Grant
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top