Solved

Confirmation dialog box then call funtion

Posted on 2009-05-11
2
502 Views
Last Modified: 2012-05-06
Hi There

I have a grid view that contains a Item Template with an ASP Button in.
I would like to have a confirmation dialogue box confirming the delete then call the Function I have written for the delete functionality.

Thanks
Stanton
<asp:GridView ID="gvAllergies" CssClass="grid" runat="server" AutoGenerateColumns="False"
                            CellPadding="4" Width="100%" DataKeyNames="ID" ForeColor="#333333" GridLines="Horizontal"
                            AlternatingRowStyle-BackColor="WhiteSmoke"
                            OnRowCreated="gvAllergies_RowCreated">
                            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                            <Columns>
                            <asp:TemplateField HeaderText="View">
                                <ItemTemplate>
                                    <asp:ImageButton ID="selectAllergy" runat="server" ImageUrl="~/images/Editsml.gif"
                                        OnClick="selectAllergy_Click" CommandArgument='<%# Bind("Id") %>' />
                                </ItemTemplate>
                            </asp:TemplateField>
                                <asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type" ItemStyle-CssClass="gridrow" />
                                <asp:BoundField DataField="Onset" HeaderText="Onset" SortExpression="Onset" ItemStyle-CssClass="gridrow" />
                                <asp:BoundField DataField="OnCard" HeaderText="On Card" SortExpression="OnCard" ItemStyle-CssClass="gridrow" />
                                <asp:BoundField DataField="OnReport" HeaderText="On Report" SortExpression="OnReport" ItemStyle-CssClass="gridrow" />
                                <asp:BoundField DataField="Confidential" HeaderText="Confidential" SortExpression="Confidential" ItemStyle-CssClass="gridrow" />
                                <asp:TemplateField HeaderText="Delete">
                                 <ItemTemplate>
                                    <asp:ImageButton ID="DeleteAllergy" runat="server" ImageUrl="~/images/Deletesml.gif"
                                        OnClick="DeleteAllergy_Click" CommandArgument='<%# Bind("ID") %>' />
//Onclick Here I would first like a confirmation dialogue the call the delete function.
 
                                </ItemTemplate>
                            </asp:TemplateField>
                            </Columns>
                            <HeaderStyle CssClass="gridhead" />
                            <RowStyle CssClass="gridrow" />
                            <EmptyDataTemplate>
                                <span class="gridrow">There are no current Allergies. Click the button above to add a new Allergy.</span>
                            </EmptyDataTemplate>
                        </asp:GridView>

Open in new window

0
Comment
Question by:Stanton_Roux
2 Comments
 
LVL 9

Expert Comment

by:tillgeffken
ID: 24352345
0
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 500 total points
ID: 24352403
Hi Stanton_Roux,
Try this:

 <asp:ImageButton ID="DeleteAllergy" runat="server" ImageUrl="~/images/Deletesml.gif"
                                        OnClick="DeleteAllergy_Click" CommandArgument='<%# Bind("ID") %>'  onClientClick="javascript: return confirm('Are you sure to remove this item?');"/>

 
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question