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:
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?');"
/>
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.
No comments:
Post a Comment