Article information
Article relates to
RadUpload
Created by
Kiril Stanoev
Last modified
03.01.2011
Last modified by
Tina Stancheva
private
void
radUpload_FileUploaded(
object
sender, FileUploadedEventArgs e)
{
RadUploadSelectedFile uploadedFile = e.SelectedFile;
// CustomData is a Dictionary property that stores the new file name in value of a key.
// This key is set in the RadUploadHandler.ashx.cs
string
newFileName = e.HandlerData.CustomData[
"NewFileName"
].ToString();
if
(
this
.radUpload.CurrentSession.FileNameUploadItem.ContainsKey(uploadedFile.Name))
RadUploadItem item =
.radUpload.CurrentSession.FileNameUploadItem[uploadedFile.Name];
(item !=
null
)
// Retrieve the TextBlock that will hold new file name
FrameworkElement element = GetCustomTagControl(item,
);
(element !=
TextBlock textBlock = element
as
TextBlock;
(textBlock !=
textBlock.Text = newFileName;
textBlock.Visibility = Visibility.Visible;
}
static
FrameworkElement GetCustomTagControl(DependencyObject control,
name)
for
int
i = 0; i < VisualTreeHelper.GetChildrenCount(control); i++)
DependencyObject child = VisualTreeHelper.GetChild(control, i);
FrameworkElement element = child
FrameworkElement;
(0 ==
.Compare(element.Name, name, StringComparison.InvariantCultureIgnoreCase))
return
element;
element = GetCustomTagControl(child, name);
;
public
class
MyUploadHandler : Telerik.Windows.RadUploadHandler
override
Dictionary<
,
> GetAssociatedData()
GetFilePath(
fileName)
newFileName =
.Empty;
> dict =
base
.GetAssociatedData();
(!
.IsNullOrEmpty(newFileName))
dict.Add(
.newFileName);
dict;
fileName =
.GetFilePath(
.GetFileName(fileName));
fileName;
GetFileName(
.IsNewFileRequest())
.ResultChunkTag =
.Format(
" [{0:yyyymmdd_hhmmss}]"
, DateTime.Now);
else
.FormChunkTag !=
.FormChunkTag;
.ResultChunkTag !=
i = fileName.LastIndexOf(
'.'
(i >= 0)
fileName = fileName.Insert(i,
.ResultChunkTag);
.newFileName = fileName;
Resources Buy Try