<asp:Button runat="server" ID="btnUserDelete" Text="Delete" CssClass="GreenLightButton"
OnClick="BtnUserDelete_Click"
OnClientClick="return UserDeleteConfirmation();"
meta:resourcekey="BtnUserDeleteResource1" />
I have tried:
function UserDeleteConfirmation() {
if (confirm("Are you sure you want to delete this user?"))
return true;
else
return false;
}
and
function UserDeleteConfirmation() {
if (confirm("Are you sure you want to delete this user?")) {
__doPostBack(btnUserDelete, '');
}
return false;
}
And none of them works.
Try this:
In Button call function:
In class .cs call method:
try this :
Try this:
try this :
OnClientClick="return confirm('Are you sure ?');"
Also set :CausesValidation="False"
This is a simple way to do client-side validation BEFORE the confirmation. It makes use of the built in ASP.NET validation javascript.
Source: Client Side Validation using ASP.Net Validator Controls from Javascript
You can put the above answers into one line like this. And you don't need to write the function.