Handle exception and static method

  1. #1

    Handle exception and static method

    Hi,

    I have a public static method like this
    [AjaxMethod]
    public static void ThrowException()
    {
      try
            {
                throw new Exception("An Exception was Thrown");
            }
            catch (Exception e)
            {
                Coolite.Ext.Web.ScriptManager.AjaxSuccess = false;
                Coolite.Ext.Web.ScriptManager.AjaxErrorMessage = e.Message;
            }
    }
    On client-side :
    function test() {
          Coolite.AjaxMethods.ThrowException({
          success: function(result) {
          },
    
          failure: function(errorMsg) {
            Ext.Msg.alert('Failure', errorMsg);
          }
        });
    }
    This code doesn't work.
    If I remove "static" It works fine.

    How can I use exception and static ?

    Thank you...
  2. #2

    RE: Handle exception and static method

    Hi,

    Confirm. It is a bug. The fix will be available in next public release. At this moment I can suggest to return error string (or another object) from AjaxMethod and use it in success handler
  3. #3

    RE: Handle exception and static method

    Ok, we will wait for the next release. (when will it be available ?)

    I thought use an ExtraParamsResponse to put the error msg.
    Is it possible ?
    How can I get this parameter in javascript in the success handler ?

    Thank you.
  4. #4

    RE: Handle exception and static method

    Hi,

    Just define return type instead void
    In the success handler define result argument
    success : function(result){...}
  5. #5

    RE: Handle exception and static method

    Ok, I understand.
    That is what I did.

    In fact I want to use a return string AND an ExtraParamsReponse too.
    It could be like this :
    [AjaxMethod]
    public string DoSomething()
    {
      ScriptManager.ExtraParamsResponse.Add(new Coolite.Ext.Web.Parameter("Param1", "Value1"));
      return "MyReturn string";
    }
    I get easyly the return string in the result param of the success function.
    But how to get the extra parameter ?
    In my case, the extra parameter would be set with an error string...

    Thank you.

Similar Threads

  1. Replies: 5
    Last Post: Nov 26, 2012, 2:33 PM
  2. Replies: 13
    Last Post: May 16, 2011, 1:26 PM
  3. Replies: 2
    Last Post: Apr 24, 2011, 9:14 PM
  4. [CLOSED] Global Static variables usage in DirectEvents Method
    By ogokgol in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Feb 04, 2011, 2:35 PM
  5. [CLOSED] Data Source as static web method
    By marcellus in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Dec 29, 2008, 11:29 AM

Posting Permissions