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

Replace


- OR -
File:







This example illustrates the Replace functionality in RadWordsProcessing. You can import a document of your choice, replace or highlight text in it, using regular expressions or strings and then export the document to view the result.

  • DefaultCS.aspx
  • DefaultCS.aspx.cs
  • scripts.js
  • styles.css
<%@ Page Language="c#" CodeFile="DefaultCS.aspx.cs" AutoEventWireup="true" Inherits="Telerik.WordsProcessing.Replace.DefaultCS" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <link href="styles.css" rel="stylesheet" />
    <script src="scripts.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div id="SpreadProcessing" class="demo-container">
        <div class="top">
            <div class="demo-container">
                <asp:Image ImageUrl="./Images/SampleDocumentImage.png" ID="SampleDocumentImage" runat="server" />
            </div>
            <telerik:RadButton RenderMode="Lightweight" Width="200px" Text="Load Template Document" ID="LoadSampleDocumentButton" AutoPostBack="false" OnClientClicked="demo.UploadSampleDocument" runat="server" /><br />
            <asp:Label Text="- OR -" ID="OrLabel" runat="server" /><br />
            <telerik:RadAsyncUpload RenderMode="Lightweight" runat="server" ID="RadAsyncUpload1" HideFileInput="true" OnClientFileUploaded="demo.OnClientFileUploaded" OnClientValidationFailed="demo.OnClientValidationFailed"
                OnFileUploaded="RadAsyncUpload1_FileUploaded" AllowedFileExtensions=".docx,.rtf,.txt,.html" />
            <div class="fileImages">
                <span class="column">
                    <telerik:RadButton RenderMode="Lightweight" Width="200px" ID="Button1" Text="Load Custom Document" AutoPostBack="false" OnClientClicked="demo.UploadFile" runat="server"
                        ToolTip="Please load a file with one of the following extensions: .docx, .rtf, .html or .txt" />
                </span>
            </div>
        </div>
        <span>File: </span>
        <asp:Label Text="" ID="FileLabel" runat="server" />
        <br />
        <br />
        <div class="formContainer">
            <div>
                <asp:Label ID="Label1" Text="Method:" runat="server" AssociatedControlID="MethodComboBox" /><br />
                <telerik:RadComboBox RenderMode="Lightweight" ID="MethodComboBox" runat="server" Width="140px" OnClientSelectedIndexChanged="demo.CheckReplaceMethod">
                    <Items>
                        <telerik:RadComboBoxItem Value="1" Text="Replace Text" Selected="true" />
                        <telerik:RadComboBoxItem Value="2" Text="Replace Styling" />
                    </Items>
                </telerik:RadComboBox>
            </div>
            <div>
            <asp:Label Text="Find Word:" ID="FindWordLabel" runat="server" AssociatedControlID="FindWhatTextBox" /><br />
            <telerik:RadTextBox RenderMode="Lightweight" ID="FindWhatTextBox" runat="server" CssClass="radPreventDecorate"></telerik:RadTextBox>
            </div>
            <div>
                <asp:Label Text="Replace With:" ID="ReplaceWithLabel" runat="server" AssociatedControlID="ReplaceWithTextBox" /><br />
                <telerik:RadTextBox RenderMode="Lightweight" ID="ReplaceWithTextBox" runat="server" CssClass="radPreventDecorate"></telerik:RadTextBox>
            </div>
        </div>
        <br />
        <br />
        <div class="checkboxContainer">
            <asp:CheckBox Text="Match Case" ID="MatchCaseCheckBox" runat="server" />
            <asp:CheckBox Text="Match Whole Word" ID="MatchWholeWordCheckBox" runat="server" />
            <asp:CheckBox Text="Use Regular Expressions" ID="RegExCheckBox" runat="server" />
        </div>
        <br />
        <telerik:RadButton RenderMode="Lightweight" Text="Replace and Save" ID="DownloadButton" OnClientClicking="demo.CheckDownload" OnClick="SaveButton_Click" runat="server" CssClass="downloadBtn rbPrimaryButton clear" Width="150px" />
        <telerik:RadFormDecorator RenderMode="Lightweight" runat="server" DecoratedControls="All" />
    </div>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance