Enter your email address:


feedburner count

Asp.net Tip series #1 : confirm message box before performing an action ?

When a critical action such as deleting / destroying / dropping.... user /database .... is excuted, system must ask user confirm before doing that important task. How can we pop op a message box to ask user ? Use this code snippet :

  • Method 1:
Javascript :
<script language="JavaScript">

<!--

function confirm_delete()

{

if (confirm("Do you want to delete ?")==true)

return true;

else

return false;

}

-->

</script>

In code behind, add this custom attribute to action control , in this example a button control named btnDelete :
lbtn.Attributes.Add("onclick", "return confirm_delete();");

  • Method 2 : Just add this code snippet in code behind :

lbtn.Attributes.Add("onclick", "return confirm('Do you want to delete ?')");




blog comments powered by Disqus