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

Multiple dictionaries on the same page

This solution allows you to have multiple RichTextBox instances on the same .aspx page use different dictionary files for the spell checking function.

 

You’ll need to override the spellcheck toolbar button on one of RichTextBox instances so that it calls a custom function to use the appropriate dictionary. I've included code below for achieving this - the other RichTextBox on the page will use the page culture to determine its dictionary.

 

This example needs a folder called Dictionaries that contains the fr-FR.dictionary in the root of the Web Application. This code overrides the existing SpellCheck function call so you just click the same spell check button as before.

 

You’d add the following code for the RichTextBox instance (RichTextBox1 in this case) for which you want to spell check in French. The other instance on the page (RichTextBox2 for example) will use the appropriate dictionary based on the Page culture setting.

 

in .aspx.cs -

 

protected RichTextBoxControl.ToolbarButton toolButton;

 

In page_load -

 

toolButton = new RichTextBoxControl.ToolbarButton("SpellCheck", true);

                        toolButton.ClientOnClickFunction = "RTB_SpellCheckFrench";

                        this.RichTextBox1.CreateToolbarButton(toolButton);

 

You' d then add javascript code like the following -

 

<script type="text/javascript" language="javascript">

 

function RTB_SpellCheckFrench(editor,htmlMode)

{

  var objId = editor.name.replace('_x5','');

  eval('CopyData'+objId+'()');

  RTB_CheckSpellingFrench(objId,'/RTBTest_4/spellcheck.aspx', editor)

}

  

function RTB_CheckSpellingFrench(strBody, strURL, editor)

{

 pubBody = strBody;

 pubURL = strURL;

 var strTextArea = '';

 var oElement = document.getElementById(pubBody);

 if (oElement) strTextArea = oElement.value;

 spIFrame.document.open()

 spIFrame.document.writeln('<HTML>')

 spIFrame.document.writeln('<HEAD>')

 spIFrame.document.writeln('<TITLE>RichTextBox Spell Checker</TITLE>')

 spIFrame.document.writeln('</HEAD>')

 spIFrame.document.writeln('<BODY bgcolor=\'threedface\' topmargin=0 leftmargin=0 rightmargin=0 bottommargin=0 style=\'cursor:wait;\'>')

 spIFrame.document.writeln('<span style=\'width:100%;height:18px;font-size:10pt;font-family:MS Shell Dlg;\'>Loading . . .</span>')

 spIFrame.document.writeln('<form action=\'\' method=\'POST\' name=\'SpellingForm\'>')

 spIFrame.document.writeln('<input type=\'Hidden\' name=\'CurrentText\' value=\'\'>')

 spIFrame.document.writeln('<input type=\'Hidden\' name=\'SpellCheck\' value=\'true\'>')

 spIFrame.document.writeln('<input type=\'hidden\' name=\'targetClientID\' value=\'\'>')

 spIFrame.document.writeln('<input type=\'hidden\' name=\'setUICulture\' value=\'fr-FR\'>')

 spIFrame.document.writeln('<input type=\'hidden\' name=\'setCulture\' value=\'fr-FR\'>')

 spIFrame.document.writeln('<input type=\'hidden\' name=\'SpellCheckerCultureBehavior\' value=\'1\'>')

 spIFrame.document.writeln('<input type=\'hidden\' name=\'SpellCheckerDictionaryPath\' value=\'\'>')

 spIFrame.document.writeln('<input type=\'hidden\' name=\'SpellCheckerDictionaryUrl\' value=\'~/dictionaries\'>')

 

 spIFrame.document.writeln('</form>')

 spIFrame.document.writeln('</BODY>')

 spIFrame.document.writeln('</HTML>')

 spIFrame.document.close()

 

 spIFrame.document.SpellingForm.action=pubURL

 spIFrame.document.SpellingForm.CurrentText.value=strTextArea;

 spIFrame.document.SpellingForm.targetClientID.value=pubBody;

 spIFrame.document.SpellingForm.submit();

 

 RTB_showDialog(editor, RTB_spellCheckDialog,'','SpellChecker');

}

                 

</script>

 

See related article - Multiple cultures on one page




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