Hi guys,
In this post you provided an example demonstrating how to return a custom message to the client using the RadUpload control. I tried following the code but unfortunately it appears it was written for an earlier version of the RadUpload control. The constants RadUploadConstants.ParamNameFileIdent and RadUploadConstants.ParamNameFilePath no longer exist. Can you please provide an updated example using the Q2 2010 controls (or later)? Please make it simple just like the example I mentioned earlier.
Thanks in advance.
In this post you provided an example demonstrating how to return a custom message to the client using the RadUpload control. I tried following the code but unfortunately it appears it was written for an earlier version of the RadUpload control. The constants RadUploadConstants.ParamNameFileIdent and RadUploadConstants.ParamNameFilePath no longer exist. Can you please provide an updated example using the Q2 2010 controls (or later)? Please make it simple just like the example I mentioned earlier.
Thanks in advance.
9 Answers, 1 is accepted
0
Hi iCeMAn,
You can see an updated code example of the same functionality in our help here. Please let us know if you need further assistance with this.
Greetings,
Alex Fidanov
the Telerik team
You can see an updated code example of the same functionality in our help here. Please let us know if you need further assistance with this.
Greetings,
Alex Fidanov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
iCeMAn
Top achievements
Rank 1
answered on 25 Nov 2010, 02:42 PM
Thanks for the response.
I read that help topic already and tried to follow the code but could not get it to work. I then searched your site for examples and found one, but unfortunately it was built using an older version of the controls. I'll get straight to the point with my problem.
I have the following code in my upload handler:
I also have this code on the client:
In my handler, when the statement _returnMessage = ProcessUploadedFiles() is executed and processing fails (for whatever reason), the details are stored in the _returnMessage variable. At present, if file processing fails, e.HandlerData.Message and e.HandlerData.CustomData are both empty. I wish to populate either of these fields with the value of _returnMessage from the server side so that I can display a custom message at the client. How do I achieve this?
I read that help topic already and tried to follow the code but could not get it to work. I then searched your site for examples and found one, but unfortunately it was built using an older version of the controls. I'll get straight to the point with my problem.
I have the following code in my upload handler:
Public
Overrides
Function
SaveChunkData(
ByVal
filePath
As
String
,
ByVal
position
As
Long
,
ByVal
buffer()
As
Byte
,
ByVal
contentLength
As
Integer
,
ByRef
savedBytes
As
Integer
)
As
Boolean
Dim
_result
As
Boolean
=
MyBase
.SaveChunkData(filePath, position, buffer, contentLength, savedBytes), _
_returnMessage
As
String
, _
_fileName
As
String
'was chunk successfully saved?
If
_result
Then
If
IsFinalUploadRequest()
Then
'process uploaded files
_returnMessage = ProcessUploadedFiles()
If
Not
String
.IsNullOrEmpty(_returnMessage)
Then
'file processing failed
'file processing failed
_result =
False
'return custom message to client
_fileName = GetQueryParameter(RadUploadConstants.ParamNameFileName)
AddReturnParam(RadUploadConstants.ParamNameMessage, _returnMessage)
AddReturnParam(RadUploadConstants.ParamNameSuccess,
False
)
AddReturnParam(RadUploadConstants.ParamNameFileName, _fileName)
AddReturnParam(RadUploadConstants.ParamNameFinalFileRequest,
True
)
End
If
End
If
End
If
'was file successfully processed?
Return
_result
End
Function
I also have this code on the client:
Private
Sub
ucManifest_FileUploadFailed(
ByVal
sender
As
Object
,
ByVal
e
As
FileUploadFailedEventArgs)
Handles
ucManifest.FileUploadFailed
If
e.HandlerData.IsSuccess
Then
'successful upload
ElseIf
Not
String
.IsNullOrEmpty(e.HandlerData.Message)
Then
e.ErrorMessage = e.HandlerData.Message
ElseIf
e.HandlerData.CustomData.Count = 0
Then
'custom data empty
Else
'TODO: display custom data
End
If
End
Sub
In my handler, when the statement _returnMessage = ProcessUploadedFiles() is executed and processing fails (for whatever reason), the details are stored in the _returnMessage variable. At present, if file processing fails, e.HandlerData.Message and e.HandlerData.CustomData are both empty. I wish to populate either of these fields with the value of _returnMessage from the server side so that I can display a custom message at the client. How do I achieve this?
0
Accepted
Hello iCeMAn,
I apologize for the delayed response. Please try using the AddReturnFileParam method instead of AddReturnParam and let us know if the ErrorMessage property of the event args of the FileUploadFailed event or the HandlerData are still empty.
Greetings,
Alex Fidanov
the Telerik team
I apologize for the delayed response. Please try using the AddReturnFileParam method instead of AddReturnParam and let us know if the ErrorMessage property of the event args of the FileUploadFailed event or the HandlerData are still empty.
Greetings,
Alex Fidanov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
iCeMAn
Top achievements
Rank 1
answered on 03 Dec 2010, 03:31 PM
Yes that did the trick! The ErrorMessage property is no longer empty, which is sufficient for my project. The HandlerData property is still empty but I'll toy around with that some more. I have two remaining questions:
1. What's the difference between AddReturnFileParam and AddReturnParam?
2. How do I know which one to use?
Thanks again.
1. What's the difference between AddReturnFileParam and AddReturnParam?
2. How do I know which one to use?
Thanks again.
0
Jonx
Top achievements
Rank 2
answered on 04 Dec 2010, 10:17 PM
AddReturnFileParam does return things specificaly for a given file. It calls AddReturnParam.
What I want to ask is if AddReturnParam is does for us to use or is only internal.
How can the things returned throught AddReturnParam be read on the client?
What I want to ask is if AddReturnParam is does for us to use or is only internal.
How can the things returned throught AddReturnParam be read on the client?
0
Hi John,
The messages returned to the client can be accessed in the Handler data of the event arguments. For example, in FileUploaded or FileUploadFailed event, you will be able to get the message through the e.HandlerData property. You should use AddReturnFileParam if the message is specific to a file.
Kind regards,
Alex Fidanov
the Telerik team
The messages returned to the client can be accessed in the Handler data of the event arguments. For example, in FileUploaded or FileUploadFailed event, you will be able to get the message through the e.HandlerData property. You should use AddReturnFileParam if the message is specific to a file.
Kind regards,
Alex Fidanov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Jonx
Top achievements
Rank 2
answered on 09 Dec 2010, 12:35 AM
Hello Alex,
Thank you for your help.
In the meantime you already got my detailed report about what I found unclear in your documentation ;)
Kind regards,
John.
Thank you for your help.
In the meantime you already got my detailed report about what I found unclear in your documentation ;)
Kind regards,
John.
0
mark
Top achievements
Rank 1
answered on 15 Dec 2011, 02:39 PM
I have extensively modified the RadFileUploader to support high scale distributed uploading on Windows Azure blob storage. In order to do this, I save chunks temporarily into blob storage and then merge at the end. Saving to local storage on the server is not scalable as I cannot garauntee that all upload requests will hit the same server in Windows Azure if I have >1 instance running.
Therefore, when I recognize this is the first chunk of a file I generate a unique ID that will be its final merged filename in BLOB storage. When I reach the final chunk to save, I perform the merge on all the parts stored in temporary blob storage into a single blob with a filename of this unique ID that I originally generated.
The Problem: My Silverlight client does not know about this unique ID because it is generated during the save chunking process server side.
EXPECTED RESULTS: I use AddReturnFileParamto send the unique ID back down to the client and retrieve this unique ID from the FileUploadEventArgs.HandlerData.CustomData property on the event args of the FileUploaded event.
ACTUAL RESULTS: I use AddReturnFileParamto send the unique ID back down to the client and retrieve this unique ID from the FileUploadEventArgs.HandlerData.CustomData property on the event args of the FileUploaded event. But the CustomData dictionary is EMPTY.
Therefore, when I recognize this is the first chunk of a file I generate a unique ID that will be its final merged filename in BLOB storage. When I reach the final chunk to save, I perform the merge on all the parts stored in temporary blob storage into a single blob with a filename of this unique ID that I originally generated.
The Problem: My Silverlight client does not know about this unique ID because it is generated during the save chunking process server side.
EXPECTED RESULTS: I use AddReturnFileParamto send the unique ID back down to the client and retrieve this unique ID from the FileUploadEventArgs.HandlerData.CustomData property on the event args of the FileUploaded event.
ACTUAL RESULTS: I use AddReturnFileParamto send the unique ID back down to the client and retrieve this unique ID from the FileUploadEventArgs.HandlerData.CustomData property on the event args of the FileUploaded event. But the CustomData dictionary is EMPTY.
0
Hi Mark,
In order to return the ID to the client and access it through the FileUploadEventArgs.HandlerData.CustomData property, you'll have to override the RadUploadHandler GetAssociatedData method and add the ID to the Dictionary it defines. This method prepares a dictionary for associated (custom) data returned to the client on each Final-file-request.
You can find more information about returning parameters to the server here. Please give this approach a try and let us know how it goes.
Kind regards,
Tina Stancheva
the Telerik team
In order to return the ID to the client and access it through the FileUploadEventArgs.HandlerData.CustomData property, you'll have to override the RadUploadHandler GetAssociatedData method and add the ID to the Dictionary it defines. This method prepares a dictionary for associated (custom) data returned to the client on each Final-file-request.
You can find more information about returning parameters to the server here. Please give this approach a try and let us know how it goes.
Kind regards,
Tina Stancheva
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>