Outlook-like Functionality

3 posts, 0 answers
  1. Chris
    Chris avatar
    43 posts
    Member since:
    Aug 2008

    Posted 11 Mar 2009 Link to this post


    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. Chris
    Chris avatar
    43 posts
    Member since:
    Aug 2008

    Posted 11 Mar 2009 Link to this post

    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"
        <form id="testForm" runat="server"
        <script language="javascript"
            function spellCheck()  
                var spell = $find('<%= radSpellChecker.ClientID %>');  
            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 %>");  
            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 == '') {  
            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 %>");  

        <telerik:RadScriptManager ID="radScriptManager" runat="server" /> 
            <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"  
                OnClientCheckFinished="checkFinished" OnClientCheckStarted="checkStarted" OnClientCheckCancelled="checkCancelled" /> 
    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 

  3. Lini
    Lini avatar
    2144 posts

    Posted 19 Mar 2009 Link to this post


    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,
    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.
Back to Top