Knowledgebase Home Page  >  RapidSpell Web ASP.NET  >  Behavior Customization
Search the Knowledge Base
Is it possible to spell check only a user's selection?
https://keyoti.com/kb/Default.aspx?ToDo=view&questId=41&catId=55

Options

Print this page
Email this to a friend
It is, with the caveat that this is only supported in browsers which support the Javascript property "document.selection" (i.e. IE).
 
Set the TextComponentInterface property to "Custom" (this allows us to override the way the text to check is retreived, so we can get the selection if there is one, rather than all the text) and paste this block on your page;
 
  <script>
  function RSCustomInterface(tbElementName){
   this.tbName = tbElementName;
   this.getText = getText;
   this.setText = setText;
   this.selection;
   this.selectedRange;
   function getText(){
    this.selection = document.selection;
    this.selectedRange = this.selection.createRange();
    if(this.selection.type == 'Text'){
     return this.selectedRange.text;
    } else {
     return document.getElementById(this.tbName).value;
    }
   }
   function setText(text){
    if(this.selection.type == 'Text'){
     this.selectedRange.text = text;
    } else {
     document.getElementById(this.tbName).value=text;
    }
    
   }
  }
  </script>
 
It is advisable to make the popup modal to avoid users changing the selection during checking.
 
 
Complete page example
 
<%@ Register TagPrefix="rapidspellweb" Namespace="Com.Keyoti.RapidSpell" Assembly="Keyoti.RapidSpellWeb" %>
<%@ Page language="c#" Codebehind="Modal.aspx.cs" AutoEventWireup="false" Inherits="RapidSpellWeb_Demo_CSharp.Modal" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
 <HEAD>
  <title>Modal</title>
  <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
  <meta name="CODE_LANGUAGE" Content="C#">
  <meta name="vs_defaultClientScript" content="JavaScript">
  <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
  <script>
  function RSCustomInterface(tbElementName){
   this.tbName = tbElementName;
   this.getText = getText;
   this.setText = setText;
   this.selection;
   this.selectedRange;
   function getText(){
    this.selection = document.selection;
    this.selectedRange = this.selection.createRange();
    if(this.selection.type == 'Text'){
     return this.selectedRange.text;
    } else {
     return document.getElementById(this.tbName).value;
    }
   }
   function setText(text){
    if(this.selection.type == 'Text'){
     this.selectedRange.text = text;
    } else {
     document.getElementById(this.tbName).value=text;
    }
    
   }
  }
  </script>
 </HEAD>
 <body MS_POSITIONING="GridLayout">
  <form id="Modal" method="post" runat="server">
   <asp:Label id="Label1" style="Z-INDEX: 101; LEFT: 21px; POSITION: absolute; TOP: 37px" runat="server"
    Font-Names="Arial">Modal PopUp Function</asp:Label>
   <asp:HyperLink id="HyperLink2" style="Z-INDEX: 104; LEFT: 21px; POSITION: absolute; TOP: 322px"
    runat="server" NavigateUrl="default.aspx" Font-Names="Arial">Main Page</asp:HyperLink>
   <asp:TextBox id="TextBox1" style="Z-INDEX: 102; LEFT: 21px; POSITION: absolute; TOP: 83px" runat="server"
    TextMode="MultiLine" Width="376px" Height="158px">How to use modal pop-ups;
1. Just set the "Modal" property in the RapidSpellWebLauncher Control, to true
</asp:TextBox>
   <RapidSpellWeb:RapidSpellWebLauncher id="RapidSpellWebLauncher1" style="Z-INDEX: 103; LEFT: 21px; POSITION: absolute; TOP: 273px"
    runat="server" Modal="True" TextComponentName-Length="8" TextComponentName="TextBox1" RapidSpellWebPage-Length="10"
    RapidSpellWebPage="PopUp.aspx" TextComponentInterface="Custom">
    <Button BorderWidth="" BorderColor="" ForeColor="" BackColor="" Height="" Width="" CssClass=""
     type="button" value="Check Spelling"></Button>
   </RapidSpellWeb:RapidSpellWebLauncher>
  </form>
 </body>
</HTML>

Related Questions:

Attachments:

No attachments were found.
'; var pathToKB = 'https://keyoti.com/kb'; var qParentCatId = 55; function PrintPage() { // Open the window to print this page var x = window.open("PrintQuestion.html", "printpage", "toolbar=1, scrollbars=1"); } function EmailToFriend() { xPos = screen.availWidth / 2 - 250; yPos = screen.availHeight / 2 - 215; // Open the window to email this question to a friend window.open("EmailQuestion.aspx?questId=" + pkQuestId + "&catId=" + qParentCatId, "emailpage", "width=500, height=430, toolbar=1, scrollbars=1, left=" + xPos + ", top=" + yPos); }