Asp.net Display confirmation message on button click - Free Asp.Net,MVC,AngularJs,Jquery,Javascript,Sql Server,WCF,Entity framework snippets and tutorial

Asp.net Display confirmation message on button click

Introduction: In this article I will explain how to display confirmation message on button click in asp.net

Description:
We show the confirmation message before perform any action like delete, insert, update etc…

Method 1: 
We can show the confirmation message using Onclientclcik event of button as mention in below given example:
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" OnClientClick="return confirm('Are you sure you want to perform this action?');"
 /> 
Method 2:
We can also show the confirmation message using JavaScript. Add the below given script to head tag of page:
<script>
       function Confirmessage() {
           var message = confirm("Are you sure you want to perform this action?");
           if (message) {
             return true;
         }
         else
           {
           return false;
       }   
       }
   </script>

After that call the JavaScript function Confirmessage() on Onclientclick event of button.
<asp:Button ID="Button1" runat="server" OnClientClick="Confirmessage()"  Text="Button" onclick="Button1_Click" />

In this article we learn how to show the confirmation message on button click in asp.net. I hope you enjoyed this article. 

What do you think about this article?

If you found this article useful, please share and follow on Facebook, Twitter, Google Plus and other social media websites. To get free updates subscribe to newsletter. Please put your thoughts and feedback in comments section.

Share this

Share on FacebookTweet on TwitterPlus on Google+


EmoticonEmoticon