Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

modalpopupextender cancel button working as if it is doing postback

Tags:

ajax

asp.net

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..

like image 558
Passenger Avatar asked Mar 25 '23 09:03

Passenger


1 Answers

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>
like image 70
Denys Wessels Avatar answered Apr 08 '23 02:04

Denys Wessels