Knowledgebase Home Page  >  RapidSpell Web ASP.NET  >  Misc
Search the Knowledge Base
How can I spell check custom data structures generated on the client side?
https://keyoti.com/kb/Default.aspx?ToDo=view&questId=91&catId=60

Options

Print this page
Email this to a friend
The custom interface mechanism in RapidSpellWebLauncher allows alot of flexibility with where the text for the spell checker comes from and goes to.  This allows your users to spell check any data you can accumulate on the page in Javascript data structures for example.
 
 
In the example below we set TextComponentInterface to Custom and then write a small block of Javascript to get and set the text.
 
  function RSCustomInterface(tbElementName){
   this.tbName = tbElementName;
   this.getText = getText;
   this.setText = setText;
   function getText(){
    //send data to spell checker
    return data[0]+"\n"+data[1]+"\n"+data[2];
   }
   function setText(text){
    //return data to structure
    data = text.split("\n");
    alert("data changed to:   "+data.join(" - "));
   }
   }
 
The data to be checked is stored in a simple array, the spell checker checks it and then returns the text to the array.  This is of course a very simple example, but the possibilities are mostly limited by imagination.  The trick to working in this way is bundling up all the text into one string in the 'getter', and unbundling it in the 'setter' - this can also be done with XML tags to mark the data regions (note if you set IgnoreXML to true, the XML tags themselves won't be spell checked or shown to the user) for example.
 
 
Example (Requires a page called PopUp.aspx which can be copied from our example projects).
 
<%@ Page language="c#" AutoEventWireup="false"%>
<%@ Register TagPrefix="rapidspellweb" Namespace="Com.Keyoti.RapidSpell" Assembly="Keyoti.RapidSpellWeb" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
 <HEAD>
  <title>CustomDataStructure</title>
  <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
  <meta name="CODE_LANGUAGE" Content="C#">
  <meta name="vs_defaultClientScript" content="JavaScript">
  <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
  <script>
   var data = new Array();
   data[0] = "thiss is question 1";
   data[1] = "thsi is question 2";
   data[2] = "thsi is quuestion 3";
  </script>
  
  
  <SCRIPT type="text/javascript">
  function RSCustomInterface(tbElementName){
   this.tbName = tbElementName;
   this.getText = getText;
   this.setText = setText;
   function getText(){
    //send data to spell checker
    return data[0]+"\n"+data[1]+"\n"+data[2];
   }
   function setText(text){
    //return data to structure
    data = text.split("\n");
    alert("data changed to:   "+data.join(" - "));
   }
   }
  </SCRIPT>  

 </HEAD>
 <body MS_POSITIONING="GridLayout">
  <form id="Form1" method="post" runat="server">
   <RapidSpellWeb:RapidSpellWebLauncher id="RapidSpellWebLauncher1" style="Z-INDEX: 101; LEFT: 307px; POSITION: absolute; TOP: 183px"
    runat="server" RapidSpellWebPage="popup.aspx" TextComponentInterface="Custom">
   </RapidSpellWeb:RapidSpellWebLauncher>
  </form>
 </body>
</HTML>
 
 
Need help with your custom requirements?  Email support@keyoti.com

Related Questions:

Attachments:

No attachments were found.