how to add return param in handler

4 posts, 0 answers
  1. felix
    felix avatar
    9 posts
    Member since:
    Sep 2008

    Posted 24 Feb 2009 Link to this post

    I tried to add some data in the FileUploadHandler (which inherits RadUploadHandler). I want to do it in ProcessStream() after I all files are uploaded

    e.g.

     


    private List<long> returnParams;

     

    public override void ProcessStream()

     

    {

     

     

        if (this.IsFinalFileRequest())

     

        {

     

            List<long> returnParams = new List() {1,2,3};

     

     

            this.AddReturnParam(RadUploadConstants.ParamNameSuccess, true);
            this

    .AddReturnParam(RadUploadConstants.ParamNameAssociatedData, GetAssociatedData());

        }
    }

     

    public override Dictionary<string, object> GetAssociatedData()

    {

        Dictionary<string, object> dict = base.GetAssociatedData();

        dict.Add("IsAuth", true);

        if (returnParams!= null && returnParams.Count > 0)

            dict.Add("returnParams", returnParams);

        return dict;

    }

     

     


    However, the object is not being set in FileUploadedEventArgs
     

     

     

    What is the proper way to do that? I also want to set the object in FileUploadFailedEventArgs when upload fails

     

     

     

     

     

  2. Ivan
    Admin
    Ivan avatar
    519 posts

    Posted 24 Feb 2009 Link to this post

    Hi felix,

    Thank you for the interest in our upload control.

    Here is a concise article about returning custom data from the upload handler (server-side).

    About the code you sent us: I noticed that the variable returnParams is local for the ProcessStream method but you are using a variable with the same name in the GetAssociatedData method, which means that you are not returning the expected data. Please correct this issue and let me know if your problem still persists.

    All the best,
    Ivan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft banner
  4. felix
    felix avatar
    9 posts
    Member since:
    Sep 2008

    Posted 24 Feb 2009 Link to this post

    My problem still exists. Bascially it only works for value type but when I tried to return a List<T> it is not working. I tried to serialize the List to xml or json string but it also throws an exception.
  5. Ivan
    Admin
    Ivan avatar
    519 posts

    Posted 26 Feb 2009 Link to this post

    Hi felix,

    Thank you for clarifying the issue.

    Currently the upload handler does not support serialization of collections - only basic types (bool, string, int) are supported. In order to return a List you should add each list item as a separate element in the dictionary and later (on the client side) recreate your List item by item. We scheduled this issue for fixing after the upcoming Q1 release.

    We appreciate your suggestion and updated your Telerik points accordingly.

    Regards,
    Ivan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top