Wednesday, 7 March 2012

Telerik Upload control file types

I use Telerik's RadUpload control in my SharePoint project. That's why I don't define Upload control in ASPX file, but I do this from code-behind instead.

In this scenario I use RadDialogOpener class. Then I add DialogDefinition, and set FileManagerDialogParameters.
RadDialogOpener DialogOpener1;
DialogOpener1 = new RadDialogOpener();
FileManagerDialogParameters fmdp = new FileManagerDialogParameters();
fmdp.FileBrowserContentProviderTypeName = typeof(SharepointTelerikCustomProvider).AssemblyQualifiedName;
DialogDefinition mediaManager = new DialogDefinition(typeof(MediaManagerDialog), fmdp);
DialogOpener1.DialogDefinitions.Add("MediaManager", mediaManager);
The effect looks like this:
Recently I needed to create two different fields, one for uploading video, other for audio. Question is, how to change default file types of MediaManagerDialog?
I set SearchPatterns property:
fmdp.SearchPatterns = new string[] { "*.wma", "*.wav", "*.mp3", "*.m3u", "*.mid", "*.midi", "*.snd" };
for audio control and
fmdp.SearchPatterns = new string[] { "*.wmv", "*.avi", "*.mpeg", "*.mpg", "*.mpe", "*.mkv" };
for video.

Watch out for proper format: asterisk-dot-extension. Otherwise you get InvalidFileExtension message.

No comments:

Post a Comment