New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Save in External File

Test.html will be open in a new window

  • Show/Hide Border
  • Table Properties
  • Delete Table
  • Row
    • Insert Row Above
    • Insert Row Below
    • Delete Row
  • Column
    • Insert Column to the Left
    • Insert Column to the Right
    • Delete Column
  • Cell
    • Merge Cells Horizontally
    • Merge Cells Vertically
    • Split Cell Horizontally
    • Split Cell Vertically
    • Delete Cell
  • Cell Properties
  • Table Properties
  • Properties...
  • Image Map Editor
  • Properties...
  • OpenLink
  • Remove Link
  • Insert Select
  • Cut
  • Copy
  • Paste
  • Paste from Word
  • Paste Plain Text
  • Paste As Html
  • Paste Html

You can save the RadEditor content in an external text or HTML file as well as load the content from an external file in the editor by following the instructions below:

  1. Create an HTML file (test.html) in the root of your web application
  2. Declare RadEditor and an Asp.NET button in your page:
    <telerik:radeditor runat="server" ID="RadEditor1" ></telerik:radeditor>
    <asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" />
  3. To save the RadEditor content in the external HTML file when the Submit button is pressed, add the following code inside the button click eventhandler in the codebehind:
    protected string path = "test.html"; //specify the path to your file
    protected void Button1_Click1(object sender, EventArgs e)
    //Open file for writing and write content
    using (StreamWriter externalFile = new StreamWriter(this.MapPath(path), false))
    Protected path As String = "test.html"
    'specify the path to your file
    Protected Sub Button1_Click1(ByVal sender As Object, ByVal e As EventArgs)
    'Open file for writing and write content
    Using externalFile As New StreamWriter(Me.MapPath(path), False)
    End Using
    End Sub
  4. To load the external file content in the RadEditor, read the file content with the ReadFile function and assign the returned string to the Html property of RadEditor in the Page_Load event:
    protected void Page_Load(object sender, EventArgs e)
    if (!Page.IsPostBack)
    = ReadFile(Server.MapPath(path));

    protected string ReadFile(string path)
    if (!System.IO.File.Exists(path))
    return string.Empty;
    using (System.IO.StreamReader sr = new System.IO.StreamReader(path))
    return sr.ReadToEnd();

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    If Not Page.IsPostBack Then
    RadEditor1.Content = ReadFile(Server.MapPath(path))
    End If
    End Sub

    Protected Function
    ReadFile(ByVal path As String) As String
    If Not
    System.IO.File.Exists(path) Then
    Return String
    End If
    Using sr As New System.IO.StreamReader(path)
    Return sr.ReadToEnd()
    End Using
    End Function

Related Resources

  • DefaultVB.aspx
  • DefaultVB.aspx.vb
<%@ Page Theme="Default" Language="vb" Debug="true" AutoEventWireup="true" CodeFile="DefaultVB.aspx.vb"Inherits="Telerik.Web.Examples.Editor.SaveInExternalFile.DefaultVB"  %>

<%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html>
<html xmlns=''>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
<link href="../Common/styles.css" rel="stylesheet" type="text/css" />
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
<telerik:RadFormDecorator RenderMode="Lightweight" runat="server" ID="FormDecorator1" DecoratedControls="Buttons" />
    <div class="demo-containers">
    <div class="demo-container">
        <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1">
            <asp:Button ID="Button1" runat="server" Text="Save to File" OnClick="Button1_Click1"></asp:Button>
            Test.html will be open in a new window
            <br />
            <br />
        <telerik:RadWindow RenderMode="Lightweight" Title="Saved content" NavigateUrl="test.html" VisibleOnPageLoad="false"
            ReloadOnShow="true" Skin="Default" runat="server" Behaviors="Maximize,Close,Move"
            ID="RadWindow1" VisibleStatusbar="false" Width="700px" Modal="true" Height="500px">
        <telerik:RadEditor RenderMode="Lightweight" runat="server" ID="RadEditor1" SkinID="DefaultSetOfTools"
    <telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1">

Support & Learning Resources

Find Assistance