Rocky
Rocky

Reputation: 4524

Validation on confirming Alert

Script

<script language="javascript" type="text/javascript">
     function FinalFunction() {
         //Your First Script
         return  confirm('Are you sure about to submit the test?');
     }
</script>

<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="javascript:FinalFunction();" OnClick="Button1_Click" />

This script is showing the confirmation alert message but either on clicking OK or Cancel Button, the page is redirecting to another page.

What I want is when I click on the Cancel Button, the page should be on same page, it should not redirect to another page.

How do I do it?

Upvotes: 0

Views: 626

Answers (3)

Adrian Ancuta
Adrian Ancuta

Reputation: 1036

OnClientClick = "return FinalFunction();"?

Upvotes: 3

elsni
elsni

Reputation: 2053

The button does a postback, do you redirect to another page in your .NET code-behind class?

Upvotes: 0

otakustay
otakustay

Reputation: 12395

modify your function:

function FinalFunction() {
    confirm('xxx');
    return false;
}

but when would you like to redirect your page?

Upvotes: 0

Related Questions