Modalpopupextender cancel button works as if postback

I implemented the owm function for the cancel button (I use javascript for this) of the ModalPopUpExtender module instead of writing the “cancelcontrolid” property for ModalPopUpExtender. It works fine, but there is one problem with the fact that this cancel button behaves as if it were performing a postback. You must have this functionality, because when I write the "cancelcontrolid" property, it does not reset ModalPopUpExtender with default values. Please, help..

+4
source share
2 answers

Since you use the button only to execute client-side code, why you use the <asp:Button , instead, use plain HTML <input type="button" :

 <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> 
+4
source

Try it......

 <asp:button runat="server".... OnClientClick="myfunction(); return false;" /> 
+3
source

All Articles