Reputation: 1634
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function abc()
{
return confirm('are U sure?');
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="abc()"
onclick="Button1_Click" style="height: 26px" />
</div>
</form>
</body>
</html>
In the above page whether you click ok or cancel for confirmation box the processing transfer for server why?
Upvotes: 0
Views: 190
Reputation: 30500
As it is a server control, the submit even is being fired as well.
The return false (which you would get by clicking 'cancel') may stop the onclick event, however the onsubmit event is still being fired.
You could try capturing this instead of the onclick event.
Upvotes: 0
Reputation: 30892
If I understand the question correctly you are asking why when you click Button1 is it posting back to the server?
This is because its a server control.
If you want a simple client button it would look like the following:
<input type="button" value="Button" OnClick="abc()" style="height: 26px" />
This would mean no processing on the server.
Upvotes: 1