[CLOSED] Help With Confirmation Window

  1. #1

    [CLOSED] Help With Confirmation Window

    Is there a way to initiate an ajax event in javascript?

    For example, I want to pop up an ExtJS confirmation dialog in a button listener before the ajax event is fired. So I create a listener which fires before the listener that would start the ajax event. I show the confirmation window and return false in my listener because I don't want to fire the ajax event until I'm sure the user wants to continue.

    The ExtJS uses a callback function when they've clicked OK or cancel because a javascript version (like ExtJS uses) can't block (not like using alert() or confirm()). But by the time I'm in the callback, I've missed the boat.

    So I was wondering if there's a way to use confirmation and then in the callback call the handler that will invoke the ajax event?

    For now I've had to resort to calling fireevent() inside my callback with a parameter that my client-side listener looks for and if it exists will allow the event to propagate and not show the confirmation dialog. But that seems real ugly to me. I was hoping for a more elegant solution.

    Thanks!
  2. #2

    RE: [CLOSED] Help With Confirmation Window

    Hi David,

    The AjaxEvents include a "Before" and "After" property which fire client-side events before/after the AjaxEvent fires.

    The following code sample demonstrates triggering a confirmation javascript alert before the <Click> AjaxEvent fires.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register assembly="Coolite.Ext.Web" namespace="Coolite.Ext.Web" tagprefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        protected void Button1_Click(object sender, AjaxEventArgs e)
        {
            this.Label1.Text = "Button1_Click: :" + DateTime.Now.ToLongTimeString();
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>AjaxEvent with JavaScript Confirmation</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ScriptManager ID="ScriptManager1" runat="server" />
            
            <ext:Button ID="Button1" runat="server" Text="Click Me!">
                <AjaxEvents>
                    <Click OnEvent="Button1_Click" Before="return confirm('Please Confirm!');" />
                </AjaxEvents>
            </ext:Button>
            
            <ext:Label ID="Label1" runat="server" />
        </form>
    </body>
    </html>
    Hope this helps.

    Geoffrey McGill
    Founder
  3. #3

    RE: [CLOSED] Help With Confirmation Window

    *Geoffrey, can you modify your example to use Ext Messagebox for the confirm? *I have been spoiled by Coolite UI. *The default browser messagebox just doesn't cut it.
  4. #4

    RE: [CLOSED] Help With Confirmation Window



    Yes, that's exactly what I was talking about. I'm trying to use the Ext msgbox which doesn't block the caller. So is there a way to call an ajaxevent in the Ext msgbox callback?
  5. #5

    RE: [CLOSED] Help With Confirmation Window

    Hi guys,

    Unfortunately the JavaScript doesn't support modal/block operations.*
    I wrote sample which emulate it (may be it is not so nice looking but it can be good point for feature improvement for such operations)

    Here is the code:
    <%@ Page Language="C#" %>
    <%@ Import Namespace="System.Collections.Generic"%>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    *** "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
    *** <title></title>
    
    *** <script runat="server">
    ****** protected void Button1_Click(object sender, AjaxEventArgs e)
    ****** {
    ********** this.Label1.Text = "Button1_Click: :" + DateTime.Now.ToLongTimeString();
    ****** }
    *** </script>
    *** 
    *** <script type="text/javascript">
    ******* function confirmClick(button, e) {
    *********** Ext.Msg.confirm(
    *************** "Confirm",
    *************** "Are you sure?",
    *************** continueAjaxEvent.createDelegate(button, [button, e], true), 
    *************** button
    *********** );
    *********** return false;
    ******* }
    
    ******* function continueAjaxEvent(btnId, text, btnCfg, sender, e) {
    *********** if (btnId == 'yes') {
    *************** sender.ajaxEvents.click.fn.apply(sender, [sender, e]);
    *********** }
    ******* }
    *** </script>
    </head>
    <body>
    *** <form id="form1" runat="server">
    ******* <ext:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Debug" />
    ******* 
    ******* <ext:Button ID="Button1" runat="server" Text="Click Me!">
    *********** <Listeners>
    *************** <Click Fn="confirmClick" />
    *********** </Listeners>
    *********** <AjaxEvents>
    *************** <Click OnEvent="Button1_Click" />
    *********** </AjaxEvents>
    ******* </ext:Button>
    ******* 
    ******* <ext:Label ID="Label1" runat="server" />
    *** </form>
    </body>
    </html>

  6. #6

    RE: [CLOSED] Help With Confirmation Window

    It would be nice if there's a way to fire off the AjaxEvent without invoking the Before handler. That way, you can always return false in the Before handler, but in the Ext Confirm success, manually fire the AjaxEvent without invoking the Before handler again.
  7. #7

    RE: [CLOSED] Help With Confirmation Window

    jchau (1/20/2009)*It would be nice if there's a way to fire off the AjaxEvent without invoking the Before handler.* That way, you can always return false in the Before handler, but in the Ext Confirm success, manually fire the AjaxEvent without invoking the Before handler again.*
    Sorry, but I don't really understand what you are requesting. Can you provide more detail?*


    Geoffrey McGill
    Founder
  8. #8

    RE: [CLOSED] Help With Confirmation Window

    Hi guys,

    We added Confirmation to the ajax event. Please update
    Here is a code snippet:

    <ext:Button runat="server" Text="Ajax event with confirmation">
        <AjaxEvents>
            <Click OnEvent="Click">
                <Confirmation ConfirmRequest="true" Title="Title" Message="Message" />
            </Click>
        </AjaxEvents>
    </ext:Button>

Similar Threads

  1. Confirmation Window
    By dtamils in forum 1.x Help
    Replies: 0
    Last Post: Oct 11, 2011, 3:12 AM
  2. [CLOSED] [1.0] DirectEvent Confirmation
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 24, 2011, 2:06 PM
  3. [CLOSED] [1.0] Confirmation Message
    By vali1993 in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: May 30, 2011, 4:46 PM
  4. [CLOSED] Confirmation Message
    By FpNetWorth in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Mar 04, 2011, 12:58 PM
  5. confirmation window default button
    By [WP]joju in forum 1.x Help
    Replies: 0
    Last Post: Aug 13, 2009, 5:02 AM

Posting Permissions