Solved

Confirmation dialog box then call funtion

Posted on 2009-05-11
2
501 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Replace &lt; with < 14 59
Interview questions for support of a legacy ASP.NET site 4 56
C#  Radio button search for Date not DateTime 4 46
Deploying to Azure 3 26
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

816 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now