Click here to Skip to main content
15,898,708 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I had a Delete button in my page when I click the del button it should ask for the confirmation that "Are you Sure to Delete this", if YES do delete process, if cancel return to the same page.

Can anyone help me?
Posted
Updated 15-Jul-13 3:16am
v3

JavaScript
 <script type="text/javascript">
function DeleteItem() {
            if (confirm("Are you sure you want to delete ...?")) {
                return true;
            }
            return false;
        }
 </script>


C#
<asp:button id="Button1" runat="server" text="Delete" onclientclick="return DeleteItem()" xmlns:asp="#unknown" />
 
Share this answer
 
Comments
santhu888 13-Feb-14 0:42am    
For My requirement this solution is working. thank you..
Nirav Prabtani 13-Feb-14 0:47am    
welcome dear.. :)
XML
<body>

<p>Click the button to display a confirm box.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction()
{
var x;
var r=confirm("Press a button!");
if (r==true)
  {
  x="You pressed OK!";
  }
else
  {
  x="You pressed Cancel!";
  }
document.getElementById("demo").innerHTML=x;
}
</script>

</body>



Try this js implementation
 
Share this answer
 
Here is another exact similar question that has been solved:

Creating alert or confirmation box in ASP .Net[^]
 
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