modalpopupextender cancel button working as if it is doing postback

modalpopupextender cancel button working as if it is doing postback

I have implemented my owm functionality for the cancel button(I’m using javascript for that) of the ModalPopUpExtender instead of writing “cancelcontrolid” property for the ModalPopUpExtender.
It is working fine but there is one issue with that this cancel button is behaving as if it is doing postback.
It is necessary to have this functionality because when i’m writing the “cancelcontrolid” property it is not resetting the ModalPopUpExtender with the default values.
Please help..

Since you’re using the button to only execute client side code why are you using <asp:Button you should use simple HTML<input type="button" instead:

<form id="form1" runat="server">
<asp:Button ID="btnShow" runat="server" Text="Show" />
<asp:ToolkitScriptManager ID="scripManager" runat="server" />
<asp:ModalPopupExtender ID="modal" BackgroundCssClass="modalStyle" PopupControlID="popup"
    TargetControlID="btnShow" runat="server" BehaviorID="modalBehavior" />
<asp:Panel runat="server" ID="popup" CssClass="panelStyle">
    <input type="button" id="btnCancel" onclick="Hide()" value="Cancel" />
</asp:Panel>
</form>

<script type="text/javascript">
    function Hide() {
        $find("modalBehavior").hide();
    }
</script>
.
.
.
.