This is a migrated thread and some comments may be shown as answers.

how to add return param in handler

3 Answers 69 Views
Upload
This is a migrated thread and some comments may be shown as answers.
felix
Top achievements
Rank 1
felix asked on 24 Feb 2009, 11:09 AM
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

 

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Ivan
Telerik team
answered on 24 Feb 2009, 04:10 PM
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.
0
felix
Top achievements
Rank 1
answered on 24 Feb 2009, 10:47 PM
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.
0
Ivan
Telerik team
answered on 26 Feb 2009, 12:10 PM
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.
Tags
Upload
Asked by
felix
Top achievements
Rank 1
Answers by
Ivan
Telerik team
felix
Top achievements
Rank 1
Share this question
or