Using RadSpell in Custom Search Engine

4 posts, 0 answers
  1. Chase Florell
    Chase Florell avatar
    257 posts
    Member since:
    Apr 2005

    Posted 21 Oct 2008 Link to this post

    Is there an example of how to use the RadSpell in a custom search engine out side of RadEditor?

    Basically I want to create a google type search in my content management system that does something like the following.


    | My coool search | [search]
    did you mean "My cool search"?

    1)  bla bla bla, my cool search.
    http://www.mysite.com/default.aspx?id=3
  2. Lini
    Admin
    Lini avatar
    2144 posts

    Posted 24 Oct 2008 Link to this post

    Hello,

    Unfortunately, there is no easy way to use the RadSpell control without the dialog (e.g. if you want to get the suggestions for a misspelled word). However, you can use the RadEditor control and its ajax spellchecking engine to get suggestions. Here is some sample code:

    <script type="text/javascript"
    var spellService = null
    function checkWord(word) 
        if (!spellService) 
        { 
            spellService = $find("<%= spellEditor.ClientID %>").get_spellCheckService(); 
            spellService.add_complete(spellCallback); 
        } 
        spellService.spellCheck(word); 
    function spellCallback(sender, args) 
        if (args.badWords.length > 0) 
        { 
            var badWord = args.badWords[0]; 
            var suggestions = badWord.suggestionsString; 
            // suggestions now holds an array of possible spellings for the misspelled word 
        } 
    </script> 
    <input type="button" id="launchButton1" value="Spell Check" onclick="javascript:checkWord('teszt');" /><br /> 
    <div style="display:none"
    <telerik:RadEditor ID="spellEditor" runat="server"
    <Tools><telerik:EditorToolGroup><telerik:EditorTool Name="ajaxspellcheck" /></telerik:EditorToolGroup></Tools></telerik:RadEditor> 
    </div> 

    As you can see, I use a hidden RadEditor control with just the AjaxSpellCheck tool. The checkWord() function initiates an ajax request for the word you wish to check and the response is handled by the spellCallback() function. If the word was not in the spell check dictionary, the suggestions varialbe will hold an array of suggestions you can use in your search dropdown.

    All the best,
    Lini
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Chase Florell
    Chase Florell avatar
    257 posts
    Member since:
    Apr 2005

    Posted 07 Nov 2008 Link to this post

    Hmm interesting approach.  Is there any way of suggesting this functionality in the future?
  5. Rumen
    Admin
    Rumen avatar
    12848 posts

    Posted 11 Nov 2008 Link to this post

    Hi Chase,

    The implementation of the requested feature will work only for editable HTML elements such as the <iframe>. The spellchecker highlights the misspelled word by wrapping it within <span> tags with a class attribute, e.g.

    <span id="RadESpellError_2" class="RadEWrongWord">testt</span>

    However, this functionality will not work in a textbox or textarea because they could not render the <span> tags and the tags will be displayed inside the content around the misspelled word, which is not an expected behavior.

    Nevertheless, I logged your request in our Todo list and our developers will consider its implementation.

    Best regards,
    Rumen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top