Click here to Skip to main content
15,889,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
sorry for my poor english first of all,....I have a gridview in that i have button for delete option to delete a number, for that i kept pop up box in javascript, in that javascript function if i click the ok or cancel button the event is handling i need to restrict the event if we click the cancel button, please help me out from this issue
Posted

I assume you are using ASP.NET. Below is the code of button inside gridview:
C#
<asp:button id="btnDelete" runat="server" onclientclick="return confirmation();"/>

Javascript code will go like this:
C#
function confirmation() {
  if (confirm("Are you sure you want to delete this record?"))
      return true;
  else 
      return false;
}

Regards..
 
Share this answer
 
v2
ASP.NET
<ItemTemplate>
                                                                    <asp:Button ID="LinkButton1" runat="server" BorderColor="White"  BorderStyle="none" CausesValidation="false" CommandArgument='<%# Eval("CLI") %>'  CommandName="delete"   Text ="Delete" OnClientClick='<%# String.Format("javascript:DeleteCli(""{0}"");", Eval("CLI"))%>'/>
                                                                    </ItemTemplate>



JavaScript
function DeleteCli(id)
 {
       // window.open("JHProducts.asp?ID=" + id );
      var dlt = confirm("Are you sure want to delete this number?"+ id,null,"status=yes,resizable=no,left=350,top=250,width=350,height=250");
       //var dlt = confirm("Are you sure want to delete this number?");
}


this is my code
 
Share this answer
 
v4
Comments
[no name] 13-Nov-14 11:59am    
But dearwhat will this do?? The code Rohan has given try with that. You need to return true or false else how will you handle, it is confirmed or not?

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