#region
ReturnMandatoryParameters
private void ReturnMandatoryParameters(bool success, bool finalFileRequest)
{
string fileName = this.Request.Form[RadUploadConstants.ParamNameFileName];
string filePath = this.GetFilePath(fileName);
// We need all this arguments sent back to the upload control.
// Please do not remove them.
this.AddReturnParam(RadUploadConstants.ParamNameSuccess, success);
this.AddReturnParam(RadUploadConstants.ParamNameFileIdent, filePath);
this.AddReturnParam(RadUploadConstants.ParamNameFileName, fileName);
this.AddReturnParam(RadUploadConstants.ParamNameFilePath, filePath);
this.AddReturnParam(RadUploadConstants.ParamNameFinalFileRequest, finalFileRequest);
}
#endregion
Telerik.Windows.Controls.RadUploadConstants does not contain a definition for ParamNameFilePath
Does anybody know what we need to change to make this work?
9 Answers, 1 is accepted
These constants were removed for Q3. The RadUploadConstant's class members are strings that the AddReturnParam method takes as first parameter, so basically you can create your own constants and use them instead.
Regards,
Alex Fidanov
the Telerik team
Our suggestion was to create your own static class to hold the constants that aren't defined in the RadUploadConstants class. I prepared a sample project that implements that solution.
Also, you can find more info about the upload service parameters here and also check out this KB article describing some of the major changes in the control's implementation. Moreover you can find the most basic scenarios in which the control is used in the Upload KB section.
I hope that info will help you.
Regards,
Tina Stancheva
the Telerik team
//public void ProcessRequest(HttpContext context)
//{
// context.Response.ContentType = "text/plain";
// context.Response.Write("Hello World");
//}
//public bool IsReusable
//{
// get
// {
// return false;
// }
//}
#region
SaveChunkData
public override bool SaveChunkData(string filePath, long position, byte[] buffer, int contentLength, out int savedBytes)
{
bool result = base.SaveChunkData(filePath, position, buffer, contentLength, out savedBytes);
try
{
string threadID = Context.Request.QueryString["threadID"];
//string threadID = HttpContext.Current.Request.QueryString["threadID"];
//string tID = this.Request.Form["threadID"];
//string thID = this.Request.QueryString["threadID"];
//string threadID = Request.QueryString["threadID"];
if (!String.IsNullOrEmpty(this.Request.Form["threadID"]))
{
if (!SYLWebUtility.ImageHelper.VerifyDirectoryExistsForNewFile(this.GetFilePath()))
{
this.AddReturnParam(RadUploadConstants.ParamNameMessage, UserInterfaceMessages.UserInterfaceMessage.ErrorMessage(UserInterfaceMessages.Enumerations.UIErrorMessage.ProblemsAddingData, SYLWebUtility.LanguageHelper.GetLanguageIDByTwoLetterISOLanguageName()));
this.ReturnMandatoryParameters(result, this.IsFinalFileRequest());
return result;
}
if (this.IsFinalFileRequest())
{
//If the file is successfully uploaded.
if (result)
{
this.SaveFiles();
}
}
}
else
{
if (SYLWebUtility.ImageHelper.VerifyFileExists(this.GetFilePath()))
{
//Deletes the specified file. An exception is not thrown if the specified file does not exist.
System.IO.
File.Delete(this.GetFilePath());
}
}
ReturnMandatoryParameters(result,
this.IsFinalFileRequest());
return result;
}
catch (Exception)
{
if (SYLWebUtility.ImageHelper.VerifyFileExists(this.GetFilePath()))
{
//Deletes the specified file. An exception is not thrown if the specified file does not exist.
System.IO.
File.Delete(this.GetFilePath());
}
ReturnMandatoryParameters(result,
this.IsFinalFileRequest());
return result;
}
 
}
#endregion
string baseThreadID = base.Request.QueryString["threadID"];
string contextThreadID = base.Context.Request.QueryString["threadID"];
string threadID = Context.Request.QueryString["threadID"];
//string threadID = HttpContext.Current.Request.QueryString["threadID"];
//string tID = this.Request.Form["threadID"];
//string thID = this.Request.QueryString["threadID"];
//string threadID = Request.QueryString["threadTypeID"];
The threadID value is always null. Any ideas?
public override bool SaveChunkData(string filePath, long position, byte[] buffer, int contentLength, out int savedBytes)
{
bool result = base.SaveChunkData(filePath, position, buffer, contentLength, out savedBytes);
try
{
if (this.IsFinalFileRequest())
{
//If the file is successfully uploaded.
if (result)
{
string threadID = this.Request.Form["threadID"];
if (!String.IsNullOrEmpty(this.Request.Form["threadID"]))
{
if (!SYLWebUtility.ImageHelper.VerifyDirectoryExistsForNewFile(this.GetFilePath()))
{
this.AddReturnParam(RadUploadConstants.ParamNameMessage, UserInterfaceMessages.UserInterfaceMessage.ErrorMessage(UserInterfaceMessages.Enumerations.UIErrorMessage.ProblemsAddingData, SYLWebUtility.LanguageHelper.GetLanguageIDByTwoLetterISOLanguageName()));
this.ReturnMandatoryParameters(result, this.IsFinalFileRequest());
return result;
}
this.SaveFiles();
}
else
{
if (SYLWebUtility.ImageHelper.VerifyFileExists(this.GetFilePath()))
{
//Deletes the specified file. An exception is not thrown if the specified file does not exist.
System.IO.
File.Delete(this.GetFilePath());
}
}
}
}
ReturnMandatoryParameters(result,
this.IsFinalFileRequest());
return result;
}
catch (Exception)
{
if (SYLWebUtility.ImageHelper.VerifyFileExists(this.GetFilePath()))
{
//Deletes the specified file. An exception is not thrown if the specified file does not exist.
System.IO.
File.Delete(this.GetFilePath());
}
ReturnMandatoryParameters(result,
this.IsFinalFileRequest());
return result;
}
 
}
In the original post, you wanted to pass back and forth messages between the RadUpload and the RadUploadHandler, which Tina demonstrated with a sample solution in the post. Are you still not able to do this using her approach/sample code? I tested this and it worked perfectly.
Greetings,
Alex Fidanov
the Telerik team
thank you for your reply. Everything is working, what I am struggling with is that I can't read the threadID out of the querystring in the SaveChunkData method. I get intellisense, I can step through the code and the threadID is always null even though I have a threadID in the querystring. I am guessing I have no access to the HttpContext in the overriden SaveChunkData method. Here is what I have tried:
//http://localhost/myapp/User/MultiPhotoUpload.aspx?threadID=20&threadTypeID=3
//HttpContext.Current.Handler.ProcessRequest(HttpContext.Current);
HttpContext.Current.CurrentHandler.ProcessRequest(HttpContext.Current);
HttpRequest request = Context.Request;
string testRequest = request.QueryString["threadID"];
string thisFormThreadID = this.Request.Form["threadID"];
string thisThreadID = this.Request.QueryString["threadID"];
//HttpContext context = new base.Request.QueryString["threadID"];
string testThreadID = HttpContext.Current.Request.QueryString["threadID"];
string formThreadID = HttpContext.Current.Request.Form["threadID"];
//HttpContext.Current.Handler.ProcessRequest(HttpContext.Current);
string baseThreadID = base.Request.QueryString["threadID"];
string contextThreadID = base.Context.Request.QueryString["threadID"];
string threadID = Context.Request.QueryString["threadID"];
//string threadID = HttpContext.Current.Request.QueryString["threadID"];
//string tID = this.Request.Form["threadID"];
//string thID = this.Request.QueryString["threadID"];
//string threadID = Request.QueryString["threadTypeID"];
Any idea why threadID is always null?
Answer in the duplicate thread here.
Regards,
Alex Fidanov
the Telerik team