[FIXED] [V0.7] Bug on confirm event on button

  1. #1

    [FIXED] [V0.7] Bug on confirm event on button

    Hi
    When doing a return confirm on a button that has user parameters, the confirmation does not work. It does not matter if I press cancel or not. It always run the funcion
    Please see code

    
    
    
    
    <script type="text/javascript">
    
    
    function getValue(button) 
    {
        return button.getText();
    } 
    
    
    </script>
    <script runat="server">
    protected void TestEvent(object sender, AjaxEventArgs e)
    {
        Label1.SetText(e.UserParams["ButtonValue"]);
    }
    </script>
    
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title>Confirm button BUG</title>
    </head>
    <body>
    <form id="form1" runat="server">
    
    <ext:ScriptManager ID="ScriptManager1" runat="server" HideInDesign="false" />
    <ext:Button OnClientClick="return confirm('Really?')" ID="btnConfirmButton" Icon="Accept" runat="server" Text="Confirm">
    <AjaxEvents> 
    <Click OnEvent="TestEvent"><EventMask ShowMask="true"/>
    <UserParams><ext:Parameter Name="ButtonValue" Value="getValue(this)" Mode="Raw" /></UserParams>
    </Click> 
    </AjaxEvents>
    </ext:Button> 
    <ext:Label ID="Label1" runat="server" Text=""></ext:Label>
    
    
    </form>
    </body>
    </html>
    Best regards
    Mikael Jürke
  2. #2

    RE: [FIXED] [V0.7] Bug on confirm event on button

    Use:

    <ext:Button ...>
    <Listeners>
    <Click Handler="return confirm('Really?');" />
    </Listeners>
    </ext:Button>
    This will cancel your Click AjaxEvent. OnClientClick only works for AutoPostBack ;)

    Cheers,
    Timothy
  3. #3

    RE: [FIXED] [V0.7] Bug on confirm event on button

    On an additional note, Listeners are evaluated before AjaxEvents, which is really good for other scenarios where you need to cancel AjaxEvents :)

    Cheers,
    Timothy
  4. #4

    RE: [FIXED] [V0.7] Bug on confirm event on button



    Hi Mikael,

    If the OnClientClick property is set, internally we just add a Listener to the Button, although the technique in which the Listener gets added results in the event being fired after the <Click> AjaxEvent, which is fundamentally also just a <Click> Listener. This prevents the OnClientClick from cancelling the AjaxEvent.

    If you move your confirmation script into a <Click> Listener everything will work as expected.

    Example

    <ext:Button ID="Button1" Icon="Accept" runat="server" Text="Confirm">
        <Listeners>
            <Click Handler="return confirm('Really?');" />
        </Listeners>
        <AjaxEvents> 
            <Click OnEvent="TestEvent">
                <EventMask ShowMask="true"/>
                <UserParams>
                    <ext:Parameter Name="ButtonValue" Value="getValue(this)" Mode="Raw" />
                </UserParams>
            </Click> 
        </AjaxEvents>
    </ext:Button>
    We're investigating a method for ensuring the AjaxEvents get fired after all Listeners. I'll post an update as soon as some new code is available.

    Thanks for reporting the issue.
    Geoffrey McGill
    Founder
  5. #5

    RE: [FIXED] [V0.7] Bug on confirm event on button

    Thanks, that works great!

    /Mikael

Similar Threads

  1. [CLOSED] Configure the Confirm´s default button
    By RCN in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 19, 2012, 1:51 PM
  2. Replies: 9
    Last Post: Nov 15, 2011, 2:37 PM
  3. [CLOSED] Button Confirm
    By majunior in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 10, 2011, 7:38 PM
  4. Confirm Box for Delete Button in the GridPanel
    By zibrohimov in forum 1.x Help
    Replies: 1
    Last Post: Jan 17, 2011, 5:01 PM
  5. Replies: 3
    Last Post: Sep 10, 2010, 2:07 PM

Posting Permissions