Hi Telerik Team
I’m facing a problem with upload control in Silverlight. The issue is that during upload of multiple files with the control and try to validate something on upload event, if the validation is failed, the upload button disappears. We are using the e.cancel =true in the OnValidate method. And then the user cannot upload the file as the upload button is missing.
Code used
///Control
<telerik:RadUpload x:Name="radFileUploader" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Left" Margin="10,0,10,10" VerticalAlignment="Bottom"
Filter="Image Files (*.jpg;*.jpeg;*.png)|*.jpg;*.jpeg;*.png"
FilterIndex="0" MaxFileCount="5"
AllowDrop="true" Width="200"
IsAutomaticUpload="false"
OverwriteExistingFiles="True"
UploadServiceUrl="/Modules/UploadFileHandler.ashx"
IsAppendFilesEnabled="True"
FileUploadStarting="radFileUploader_FileUploadStarting"
FileUploaded="radFileUploader_FileUploaded" SingleFilePerPostRequest="False" UploadStarted="radFileUploader_UploadStarted" />
///Constructor
public UploadIconDialog()
{
InitializeComponent();
radFileUploader.AddHandler(RadUploadItem.ValidateEvent, new UploadValidateEventHandler(OnValidate));
}
///Validation Method
void OnValidate(object sender, UploadValidateEventArgs e)
{
if (txtLandscape.Text == string.Empty)
{
MessageBox.Show("Please select a landscape", "Validation", MessageBoxButton.OK);
// Here Landscape is a mandatory field.
e.Cancel = true;
}
}
//Attching parameters.
private void radFileUploader_FileUploadStarting(object sender, Telerik.Windows.Controls.FileUploadStartingEventArgs e)
{
e.FileParameters.Add("LandscapeGuid", txtLandscape.Tag);
e.FileParameters.Add("FileName", e.SelectedFile.File.Name);
}
So how can I bring back the 'upload' button so the user can upload files if needed?