OnClientCancel not functioning with ConfirmButtonExtender

Last post 07-31-2009 8:57 PM by MetalAsp.Net. 1 replies.

Sort Posts:

  • OnClientCancel not functioning with ConfirmButtonExtender

    07-31-2009, 8:36 PM
    • Member
      point Member
    • Sucka27
    • Member since 08-01-2009, 12:32 AM
    • Posts 1

    Hello,

    I’ve been using a ConfirmButtonExtender with success in my web app but have hit a snag that is making me pull my hair out.  In short, the assigned OnClientCancel function does not execute, even if the Cancel button is clicked by the user.  In fact I can assign an OnClientCancel function that doesn’t exist and compile still completes without error.  I’ve tried setting breakpoints (which are not triggered), changing the function name, deleting the extender and recreating it all with no luck.  Is this a known issue or is there something obvious that I could be doing wrong?  I’ve included some code for clarity.

    The button with attached extender:

    <asp:Button ID="btnDPKSubmit" runat="server"  CssClass="button" Text="btnDpkSubmit" 
                PostBackUrl="~/RIManager.aspx" Visible="False" 
                onclick="btnSubmit_Click" />
            <cc1:ConfirmButtonExtender ID="btnDPKSubmit_ConfirmButtonExtender" 
                runat="server" ConfirmText="" Enabled="True" TargetControlID="btnDPKSubmit" OnClientCancel="CancelClick">
            </cc1:ConfirmButtonExtender>

    <asp:Button ID="btnDPKSubmit" runat="server"  CssClass="button" Text="btnDpkSubmit" 

                PostBackUrl="~/RIManager.aspx" Visible="False" 

                onclick="btnSubmit_Click" />

    <cc1:ConfirmButtonExtender ID="btnDPKSubmit_ConfirmButtonExtender" 

               runat="server" ConfirmText="" Enabled="True" TargetControlID="btnDPKSubmit" OnClientCancel="CancelClick">

    </cc1:ConfirmButtonExtender>


    I placed a breakpoint at:
       protected void CancelClick()

        {

            _confirmed = false;

        }


    But it never gets triggered, the code goes straight to btnSubmit_Click.


    Can someone lend me a hand here?

    thanks,

    Trevor

  • Re: OnClientCancel not functioning with ConfirmButtonExtender

    07-31-2009, 8:57 PM
    Answer

    I believe OnClientCancel specifies a javascript function to call not server side method.  Instead of the code you have for CancelClick, use this as a test in your HTML markup to see it in action:

    <script type="text/javascript">
    	function CancelClick()
    	{
    		alert('In cancel handler');
    	}
    </script>
    


     

Page 1 of 1 (2 items)