Knowledge Base > RichTextBox > Implementation Knowledge Base Home | Login
Search the Knowledge Base
 
Start Search in the Following Category

Client Side Disabling of the RichTextBox editor and Toolbar Items

Firstly an example of disabling the Editor and moving focus to another element. If you don’t move the focus from the editor, it will appear disabled (greyed out) but the user can still type content.

 

<%@ Register TagPrefix="rtb" Namespace="RichTextBoxControl" Assembly="RichTextBox" %>

<%@ Page language="c#" ValidateRequest="false"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<HTML>

        <HEAD>

                <title>WebForm1</title>   

        </HEAD>

        <body>

                <form id="Form1" method="post" runat="server">

                        <RTB:RICHTEXTBOX id="RichTextBox1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px"

                                        runat="server"></RTB:RICHTEXTBOX>

                        <INPUT id="TextBox35" style="Z-INDEX: 102; LEFT: 12px; POSITION: absolute; TOP: 343px"

                                type="text">

                        <INPUT style="Z-INDEX: 103; LEFT: 231px; POSITION: absolute; TOP: 343px" onclick="setRichTextBox(true)"

                                type="button" value="Disable"> 

                        <INPUT style="Z-INDEX: 104; LEFT: 359px; POSITION: absolute; TOP: 343px" type="button"

                                value="Enable" onclick="setRichTextBox(false)"></form>

               

                <script language="javascript">

       

        document.getElementById('TextBox35').focus();

        

        function setRichTextBox(disable)

        {

          document.frames('RichTextBox1_x5').document.body.disabled =   

          disable;

         

          if (disable)

          {

              document.getElementById('TextBox35').focus();   

          }

          else

          {

              document.frames('RichTextBox1_x5').document.body.focus();

          }  

        }

                </script>

        </body>

</HTML>

 

 

Secondly if you’d like to disable/enable all the Toolbar items client side then implement the following functions –

 

function disable()

         {

             // disable RTB and OrthoToolBar dropdowns

var x=document.getElementsByTagName("select")

for (i=0; i<x.length; i++){

x[i].setAttribute('disabled',true);

}

 

// disable RTB image buttons

var x=document.getElementsByTagName("img")

for (i=0; i<x.length; i++){

x[i].setAttribute('disabled',true);

}

 

function enable ()

         {

 // enable RTB and OrthoToolBar dropdowns

var x=document.getElementsByTagName("select")

for (i=0; i<x.length; i++)

{

x[i].setAttribute('disabled',false);

 

}

 

// enable RTB image buttons

var x=document.getElementsByTagName("img")

for (i=0; i<x.length; i++)

{

x[i].setAttribute('disabled',false);

}

 




Did this page answer your question? If not, try the Forums or contact us.

Copyright Richer Components 2005. All rights reserved. No part of this article may be reproduced or transmitted in any form, by any means (electronic, photocopying, recording or otherwise) without the prior written permission of Richer Components. All brand names and product names used in this article are trade names, service marks, trademarks, or registered trademarks of their respective owners.


Knowledge Base Software - myKB.com