473,383 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Confirm before postback in grid

Dan
Hi, I have a grid of users, with a button column that does a delete. Is there anyway I can have an "Are you sure?" javascript dialog box in there between the button click and the postback to the OnItemCommand delegate?

Thanks

Dan.
Nov 18 '05 #1
1 1032
Dan,
put this javascript function on the client side of your aspx page
<script>
function confirmSubmit() { var sure=confirm("Are you sure you want to
delete?");
if (sure) return true ;
else
return false ;
}
</script>

and in the ItemdataBound event

if(e.Item.ItemType != ListItemType.Header &&
e.Item.ItemType!= ListItemType.Footer)
{
//for eg :
//Now, reference the LinkButton control that the ButtonColumn for
delete
LinkButton BtnDelete = e.Item.Cells[0].Controls[0];

BtnDelete.Attributes("onclick") = "confirmSubmit() ;"

}
This will do it.If you want to display an item value in the confirm
box modify the javascript and pass an argument with
e.Item.DataItem.

Hope this helps.
Regards,
Marshal Antony
http://dotnetmarshal.com

"Dan" <an*******@discussions.microsoft.com> wrote in message
news:9A**********************************@microsof t.com...
Hi, I have a grid of users, with a button column that does a delete. Is there anyway I can have an "Are you sure?" javascript dialog box in there
between the button click and the postback to the OnItemCommand delegate?
Thanks

Dan.

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jeremy | last post by:
I have a datagrid that users interact with to add/edit/delete, but before the .aspx submits for the delete action I want to pop up a JavaScript confirm box. If the user clicks OK on that box I...
5
by: Logger | last post by:
Help, I’m trying to implement a confirm button on an asp.net page. I have it attached to a asp:button control. In the button1 click event I call the CreateConfirmBox subroutine. The Box comes...
1
by: Billy | last post by:
Hi... I have a problem with a confirm dialog box. I want to execute some code and then prompt the user with a confirm dialog box who's message will depend on the result of the execution from...
10
by: Mike Malter | last post by:
I have scoured the web looking for an example of how to do a javascript confirm box in .NET. Is there any way to do it? Thanks.
10
by: Krista Lemieux | last post by:
I'm new to ASP.NET and I'm not use to the way things are handled with this technology. I've been told that when I have a control, I should only bind the data to it once, and not on each post back...
13
by: Chris Thunell | last post by:
I have created several grids dynamically and have added them to different HTML placeholders on a vb.net web form. The grids and controls within them come up and view beautifully when the web page...
9
by: Joe | last post by:
I have a DataGrid with a templated column that displays ImageButtons. I need to know if one of these buttons caused the postback or just another button on the form. If one of these buttons caused...
2
by: JerryK | last post by:
I have a piece of asp.net code that sets up a call to a javascript function in a controls onclick event. This javascript function displays a confirm dialog and returns the results of the confirm...
5
by: robert | last post by:
I have a dropdownlist with the autopostback set to true. I want the user to be confirm whether they do indeed want to change the value, which on post back fires a server side event...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.