Click here to Skip to main content
16,016,306 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,
i have a pop-up confirmation window on asp.net.
but unfortunately my client side javascript code do the same function.
which means i actually do that, "whether this number want to delete or not"

if i click ok button then the number has been deleted and
if i click cancel button then the number also has been deleted.

so this is my problem.
please have you look at the code below,

<script type="text/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");

}
</script>

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


regards,
stellus.
Posted
Comments
Thanks7872 14-Nov-14 9:13am    
Try adding return dlt at end of the javascript function.

return the value of confirm and it will prevent the server call if cancel button click
JavaScript
function DeleteCli(id) 
{
  return confirm("Are you sure want to delete this number?"+ id,null,"status=yes,resizable=no,left=350,top=250,width=350,height=250");
}
 
Share this answer
 
You need to return false or rather return dlt as result of your function to prevent further execution (postback) if the user selects No.

You'll also need to change your asp:Button to:
ASP.NET
<asp:button id="LinkButton1" runat="server" bordercolor="White" borderstyle="none" causesvalidation="false" commandname="delete" text="Delete" onclientclick="<%# String.Format("javascript: <b><u>return</u></b> DeleteCli(""{0}"");", Eval("CLI"))%>" xmlns:asp="#unknown" />



If this helps please take time to accept the solution. Thank you.
 
Share this answer
 

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