Learner
Learner

Reputation: 1634

Please find the error in below written code for asp + JavaScript

<script type=text/javascript>
function abc()
{
   return confirm('Are u sure');
}
</script>


<asp: Button id="btnSubmit" runat="server" onClick="btnSubmit_Click" onClientClick="abc" Text="Submit/>

When I click the button the message box appears if I hit the cancel Button still the function for onClick is called instead it should not. But if I write JavaScript code directly in the tag it works properly.

Upvotes: 0

Views: 108

Answers (1)

Jamiec
Jamiec

Reputation: 136114

onClientClick="return abc()"

the return is the essential bit.

Upvotes: 4

Related Questions