Click here to Skip to main content
15,900,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to popup confirm box after click of asp:commandfield delete button?
Posted

 
Share this answer
 
You can use the javascript alert command or use confirmbuttonextender af the ajaxcontroltoolkit. you can also make your own popup by making a div and place a message and buttons. Or u can also use modal popup extender to create your own popup. For your reference:

http://www.asp.net/ajaxlibrary/AjaxControlToolkitSampleSite/[^]

Best regards,
Eduard
 
Share this answer
 
Comments
Aja wakim 26-Nov-11 3:54am    
yeah right..
on your asp button put the javascript function on OnClientClick event.

<asp:button id="btnDel" runat="server" text="DELETE" onclientclick="delFunc()" xmlns:asp="#unknown" />


in javascript use jquery
/*this is javascript*/
function delFunc()
{
 if(confirm("Are you sure want to delete?"))
 {
  .........
   call the code behind function/method using jquery.ajax();
  .........
 }
}
 
Share this answer
 
There is many way you can handle it but this is a easy way :

Java Script Function :
JavaScript
function confirmSubmit() {
      var agree=confirm("Are You Sure ?");
      if (agree)
       return true ;
      else
       return false ;
    }


In Grid view :

OnClientClick="return confirmSubmit()"
 
Share this answer
 
v2
Try
Confirm Box In Asp.net[^] having similar question with answers.
or navigate given link
Message Box in ASP.NET 2.0[^]
and CP article-[ Buttons, Message Box, and Confirm Box in ASP.NET 3.5 ][^]
 
Share this answer
 
v2
add following code to your gridview

XML
<asp:TemplateField HeaderText="DELETE">
                                <ItemTemplate>
                                    <asp:LinkButton ID="LinkButton1" CommandArgument='<%# Eval("Primary_Key") %>' CommandName="Delete"
                                        runat="server" ForeColor="Red">
                                    Delete</asp:LinkButton>
                                </ItemTemplate>
                            </asp:TemplateField>


i hope it will solve your problem.
 
Share this answer
 
For confirm Box You can use javascript popup box.
JavaScript
Write:-
Alert.show("message"); or
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert("Message");", true);

or you can call a java script function..............
 
Share this answer
 
v2
u can use java script for this

VB
<asp:ImageButton ID="btndelete" runat="server"
                            ImageUrl="~/Admin/Images_buttons/Delete.png" onclick="btndelete_Click" OnClientClick=confirm('Do you want to delete')
 
Share this answer
 
Comments
RaviRanjanKr 27-Nov-11 15:31pm    
A suggestion :- its not a good practice to use short text words like 'u' instead of using 'You' :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900