This is a migrated thread and some comments may be shown as answers.

Outlook-like Functionality

2 Answers 102 Views
Spell
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 11 Mar 2009, 04:35 PM
Hi,

I was curious if I can make the control work kinda like the Send button in Outlook.  Basically what I want is for there to be, for example, is a text box, radSpell and a Save button.  The user clicks on the save button, if there is any misspelled words, the spell check dialog pops up.  If there are no spelling mistakes in the text box, then the dialog will not be displayed and the rest of the buttons code executes like normal.

EDIT - I've got a good start.  Just for extra information, I want to do this with a normal text box and not the radEditor control.

2 Answers, 1 is accepted

Sort by
0
Chris
Top achievements
Rank 1
answered on 11 Mar 2009, 08:33 PM
This is what I have right now.  Cause I can't get it to work properly on the click of the button.  For now I just set
everything when the text box loses focus.  Everything basically works except for the checkStarted method.  In that method
I want to see if I can check how many misspelled words there are.

<
%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" EnableEventValidation="true" %> 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
    <title></title
     
</head> 
<body> 
    <form id="testForm" runat="server"
    <script language="javascript"
        function spellCheck()  
        {  
            var spell = $find('<%= radSpellChecker.ClientID %>');  
            spell.startSpellCheck();  
        }  
  
        function checkFinished(sender, args) {  
            // Supresses the javascript alert that occurs when  
            // the spell check finishes.  
            args.suppressCompleteMessage = true;  
              
            // Fire button click event to do some server side work.  
            var button = $get("<%= btnSubmit.ClientID %>");  
            button.click();  
        }  
  
        function checkStarted(sender, args) {  
            // If no errors, don't display the dialog box.  
            // For now, don't know how to check for errors, so  
            // temporarily just checking to see if the textbox is blank.  
            if ($get("<%= txtSpellCheck.ClientID %>").value == '') {  
                args.set_cancel(true);  
            }  
        }  
  
        function checkCancelled(sender, args) {  
            // If they don't want to do the spell check, then fire off the server  
            // side work.  
            var button = $get("<%= btnSubmit.ClientID %>");  
            button.click();  
        }  



    </script>  
    <telerik:RadScriptManager ID="radScriptManager" runat="server" /> 
    <div> 
        <asp:TextBox ID="txtSpellCheck" runat="server" TextMode="MultiLine" Height="100%" onblur="spellCheck();"></asp:TextBox> 
         
        <asp:Button ID="btnSubmit" runat="server" style="display: none;" /> 
        <asp:Label ID="lblTest" runat="server"></asp:Label> 
         
        <telerik:RadSpell ID="radSpellChecker" runat="server"  
            ControlToCheck="txtSpellCheck" ButtonType="None"  
            FragmentIgnoreOptions="All" SpellCheckProvider="EditDistanceProvider" 
            SupportedLanguages="en-US,English" WordIgnoreOptions="None"  
            Skin="Office2007" 
            OnClientCheckFinished="checkFinished" OnClientCheckStarted="checkStarted" OnClientCheckCancelled="checkCancelled" /> 
    </div> 
    </form> 
</body> 
</html> 
 
Imports Telerik.Web.UI 
Imports Telerik.WebControls 
 
Partial Class _Default 
    Inherits System.Web.UI.Page 
 
    Protected Sub testForm_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles testForm.Load 
        If Not IsPostBack Then 
            txtSpellCheck.Attributes.Add("style""overflow: hidden"
        End If 
    End Sub 
 
    Protected Sub btnSubmit_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles btnSubmit.Click 
        lblTest.Text = "Server event fired from javascript." 
    End Sub 
End Class 

0
Lini
Telerik team
answered on 19 Mar 2009, 10:12 AM
Hi,

The approach you have taken will get the job done. However, you can go one step further and don't show the spell dialog unless there are errors. For this to work, you will need to place a hidden RadEditor control on the page with only one tool - spell check. I have attached the updated example page to this message.

When the blur event of your textbox is fired, I use the editor's spell checking service to check the text. If there are no errors, I submit the page. If there are errors, I call the normal RadSpell control dialog and provide the user with suggestions for the misspelled words. From then its similar to your example - when the spell check dialog is closed (spell check is finished or canceled) I submit the page. The only difference is that I added a small timeout before submitting the page when the spell check is successfully finished. This way I can ensure that the textbox value is updated properly before it is sent to the server.

Sincerely yours,
Lini
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Spell
Asked by
Chris
Top achievements
Rank 1
Answers by
Chris
Top achievements
Rank 1
Lini
Telerik team
Share this question
or