[CLOSED] How to configure a message box for the Failure handler?

  1. #1

    [CLOSED] How to configure a message box for the Failure handler?

    Hi,

    I need to display a custom error prompt message box when a DirectEvent execution returns failure. I've noticed that I couldn't use the server side MessageBox object if I set the DirectEventArgs Success property to "false" in the DirectEvent code-behind. In that case, a generic error popup is shown.

    Please suggest the best practice to achieve the desired behavior. I've been trying to do something like:

    <DirectEvents>
    <Click OnEvent="Button1_Click" Success="onSuccess();"
                                                  Failure="Ext.Msg.show({
                                                            msg     : 'Failed: '+result.errorMessage,
                                                            width   : 400,
                                                            buttons : Ext.Msg.OK,
                                                            title   : 'Error',
                                                            icon    : 'icon-error',
                                                            fn      : 'onFailure'
                                                });"
    </Click>
    </DirectEvents>
            protected void Button1_Click(object sender, DirectEventArgs e)
            {
                bool res = false;
    
                if (!res)
                {
                    e.Success = false;
                    e.ErrorMessage = "Some error occured!";
                }
            }
    However, the icon displayed is only 16x16 and, more importantly, the onFailure delegate is never invoked.
    Last edited by Daniil; Jul 20, 2012 at 2:32 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Yes, setting up
    e.Success = false;
    causes no JS script will be sent from server, just a success flag and an error message.

    Our Failure Window is not an Ext.MessageBox. Please see the showFailure method here:
    <Ext.NET sources root>\Ext.Net\Build\Ext.Net\extnet\core\direct\DirectEvent.js
    the onFailure delegate is never invoked.
    It must be a Function, not a string.
  3. #3
    Hi,

    Could you please provide a code sample to configure a message box on the client so that a large icon is displayed and a function is executed on the button click?

    Ext.Msg.show({
                msg       : 'Failed: '+result.errorMessage,
                width     : 400,
                buttons  : Ext.Msg.OK,
                title       : 'Error',
                icon       : 'icon-error',
                fn          : 'onFailure'
    });
  4. #4
    Well, the default Error icon looks to be 32x32.

    And, seems, you have missed the following comment.
    It must be a Function, not a string.
    Example
    Ext.Msg.show({
        icon     : Ext.Msg.ERROR,
        buttons  : Ext.Msg.OK,
        fn       : function (btn) {
            alert(btn);
        }
    });
  5. #5
    Quote Originally Posted by Daniil View Post
    Well, the default Error icon looks to be 32x32.

    And, seems, you have missed the following comment.

    Example
    Ext.Msg.show({
        icon     : Ext.Msg.ERROR,
        buttons  : Ext.Msg.OK,
        fn       : function (btn) {
            alert(btn);
        }
    });
    Thanks Daniil, that's what I was looking for! Could you also provide me with the link to info on all the configuration options available for Ext.Msg.show() method?
  6. #6
  7. #7
    Thanks again! Please mark this thread as resolved.

Similar Threads

  1. Replies: 15
    Last Post: Oct 28, 2011, 6:59 AM
  2. Confirm message handler
    By norphos in forum 1.x Help
    Replies: 1
    Last Post: May 18, 2011, 6:51 AM
  3. Replies: 0
    Last Post: Mar 21, 2011, 3:55 PM
  4. [CLOSED] Store request failure message
    By albayrak in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 07, 2011, 10:27 AM
  5. [CLOSED] Configure default AjaxEvent failure window
    By jchau in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jun 15, 2009, 10:55 AM

Tags for this Thread

Posting Permissions