protected void ImportDocx_Click(object sender, EventArgs e) { using (Stream docxStream = docxUpload.UploadedFiles[0].InputStream) { RadEditor1.LoadDocxContent(docxStream); } }
protected void saveBtn_Click(object sender, EventArgs e) { using (Stream docxStream = docxUpload.UploadedFiles[0].InputStream) { RadEditor1.LoadDocxContent(docxStream); } RadEditor1.ExportToDocx(); populate(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { using (FileStream initialFileStream = new FileStream(Server.MapPath("~/App_Data/" + Request.QueryString["TopicsFile"].ToString()), FileMode.Open, FileAccess.Read)) { RadEditor1.LoadDocxContent(initialFileStream); } //RadEditor1.Enabled = false; } }
protected void RadAsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e) { //the maximum allowed file inputs is one, so there should be no multiple files uploaded //see what is the uploaded file extension and attempt to import it accordingly try { string fileExt = e.File.GetExtension(); switch (fileExt) { case ".doc": case ".docx": RadEditor1.LoadDocxContent(e.File.InputStream); break; case ".rtf": RadEditor1.LoadRtfContent(e.File.InputStream); break; case ".txt": case ".html": case ".htm": using (StreamReader sr = new StreamReader(e.File.InputStream)) { RadEditor1.Content = sr.ReadToEnd(); } break; case ".md": using (StreamReader sr = new StreamReader(e.File.InputStream)) { RadEditor1.Content = sr.ReadToEnd(); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "importMarkdownScript", "TelerikDemo.setMarkdownContent();", true); } break; default: RadNotification1.Show("The selected file is invalid. Please upload an MS Word document with an extension .doc, .docx or .rtf, or a .txt/.html file with HTML content!"); break; } } catch (Exception ex) { RadNotification1.Show("There was an error during the import operation. Try simplifying the content."); } }