protected void UploadButton_Click(object sender, EventArgs e) { if (RadUploadControl.InvalidFiles.Count > 0) { StringBuilder response = new StringBuilder("<br/>There was an error while registering your template<br/>"); UploadedFile file = RadUploadControl.InvalidFiles[0]; if (file.ContentLength >= RadUploadControl.MaxFileSize) { response.Append("Maximum file size: " + RadUploadControl.MaxFileSize.ToString() + " bytes"); } else if (!RadUploadControl.AllowedFileExtensions.Contains(file.GetExtension())) { response.Append("Allowed file extensions: " + string.Join(",", RadUploadControl.AllowedFileExtensions)); } else { response.Append("Your template could not be uploaded"); } response.Append("<br/><br/>"); ErrorLabel.Text = response.ToString(); ErrorLabel.ForeColor = Color.Red; } else if (RadUploadControl.UploadedFiles.Count == 1) { string physicalPath = AppDomain.CurrentDomain.BaseDirectory; var templateteImporter = new TemplateImporter( RadUploadControl.UploadedFiles[0].GetName(), physicalPath ); bool success = templateteImporter.Import(); if (success) { ErrorLabel.Text = "Upload successful"; } else { ErrorLabel.Text = "An error occured while registering the template"; } ErrorLabel.ForeColor = Color.LightGreen; } }
protected void UploadButton_Click(object sender, EventArgs e) { if (this.RadUploadControl.InvalidFiles.Count > 0) { StringBuilder response = new StringBuilder("<br/>There was an error while registering your template<br/>"); UploadedFile file = this.RadUploadControl.InvalidFiles[0]; if (file.ContentLength >= this.RadUploadControl.MaxFileSize) { response.Append("Maximum file size: " + this.RadUploadControl.MaxFileSize.ToString() + " bytes"); } else if (!this.RadUploadControl.AllowedFileExtensions.Contains(file.GetExtension())) { response.Append("Allowed file extensions: " + string.Join(",", this.RadUploadControl.AllowedFileExtensions)); } else { response.Append("Your template could not be uploaded"); } response.Append("<br/><br/>"); this.ErrorLabel.Text = response.ToString(); this.ErrorLabel.ForeColor = Color.Red; } else if (this.RadUploadControl.UploadedFiles.Count == 1) { string physicalPath = AppDomain.CurrentDomain.BaseDirectory; var templateteImporter = new TemplateImporter( this.RadUploadControl.UploadedFiles[0].GetName(), physicalPath ); bool success = templateteImporter.Import(); if (success) this.ErrorLabel.Text = "Upload successful"; else this.ErrorLabel.Text = "An error occured while registering the template"; this.ErrorLabel.ForeColor = Color.LightGreen; } }