-
October 15th, 2002, 04:00 AM
#1
DataGrid and MessageBox
Hi all,
I have been working in the ASP.NET for 4 days and encountered a problem.
I have the DataGrid with the Button Column DELETE:
-asp:ButtonColumn Text="Del" CommandName="Delete"--/asp:ButtonColumn-
If a user clicks on the Del than appropriate record will be deleted.
Well, and I want to display the message box for confirmation before deleting (“Are you sure to delete this record?” etc.) with YES and NO buttons.
How to do this? Help, please.
Thanks in advance,
David
Last edited by David Bajgar; October 15th, 2002 at 04:04 AM.
-
October 18th, 2002, 03:45 PM
#2
-
November 5th, 2002, 09:41 AM
#3
I don't see any topic related to this question? Is anyone has any idea how to do this?
-
November 5th, 2002, 04:44 PM
#4
I found the code to handle this. Just add this code to the button which you want to display message:
btnDeleteUser.Attributes.Add ("onclick", "return confirm('Are you sure you want to delete this user?');")
-
November 6th, 2002, 04:58 PM
#5
That's cool! Can I also have something different happen if the user CANCELs?
You know; like checking for IDCANCEL returned from a dialog in a VC++ Windows app.
Where can I learn more about this 'Attributes.Add' stuff?
Last edited by RickCrone; November 6th, 2002 at 05:00 PM.
-
November 8th, 2002, 05:14 AM
#6
Hi all,
Great Stevehoang!
I spent some time how to bind the Attributes with the delete column in the grid. You can do that if you cast the delete column to the LinkButton class. So, my hint is here:
Code:
LinkButton btn;
foreach(DataGridItem item in DataGrid1.Items)
{
btn = (LinkButton)item.Cells[1].Controls[0];
btn.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this user?')");
}
David
-
June 6th, 2003, 03:18 PM
#7
how does this work
First, Thanks. This is exactly what im looking for. My question is how exactly is this working. The click event in the c# code that is associated with the button by default only executes when the confirm response is ok. Thats what i want but dont know why its working. I was hoping someone could help explain whats happening. It seems to me that the "onclick" should be a function in the web page not a fucntion in the server side code. Also how does the return confirm(...) make it work on the ok but not the cancel. Any help would be appriciated.
-
June 9th, 2003, 01:43 AM
#8
Good eample for you!
Visit me at
http://www34.brinkster.com/zeeinfo
-
June 26th, 2003, 05:05 AM
#9
hi,
For showing a message box u should use javascript function confirm for showing a message.
ex:
each button control has a property called Attribute
MyDeleteButton.Attributes("onclick") = "return confirm('Are you sure you _ wish to delete this record?');"
use the following code for performing the task
rgds
syam
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|