Solved

Confirmation dialog box then call funtion

Posted on 2009-05-11
2
503 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

710 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