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

GetRadSpell(clientID) not available during window.onload?

2 Answers 42 Views
Spell
This is a migrated thread and some comments may be shown as answers.
Steven D'Anna
Top achievements
Rank 1
Steven D'Anna asked on 22 Dec 2009, 10:56 PM
So I've seen some of the examples on the site, specifically http://www.telerik.com/help/aspnet/spell/spell_launching_upon_client-side_events.html and I can invoke the spell checker just fine on say a button click or some other UI event such as onblur of a textbox.  What I want to do is to spell check immediately when the page loads (without user interaction... steps described elsewhere on the site albeit for a previous version of the spell component: http://www.telerik.com/help/aspnet/spell/spell_spellchecking_in_htm,_html,_and_asp_files.html)

For some reason I can't get the GetRadSpell() function to return an instance of the Spell Editor like what happens when I click it from a button.  Is it a timing issue?  Can I not do this on the window.load event of the browser?  Is there a way to get my desired result?  My code is below.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SpellChecker.aspx.cs" Inherits="EditorExample.SpellChecker" %>  
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>  
<!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>  
    <title>Spell Checker</title>  
</head>  
<body>  
    <form id="form1" runat="server">  
        <asp:ScriptManager ID="ScriptManager1" runat="server">  
        </asp:ScriptManager>  
        <input type="text" id="test" value="misstake"/>  
        <telerik:RadSpell ID="RadSpell1" runat="server" ControlToCheck="test" IsClientID="True"  
            SupportedLanguages="en-US,English" />  
        <span onclick="doSpellCheck()">Click me to spell check</span>  
    </form>  
    <script type="text/javascript"
        function doSpellCheck() { 
            GetRadSpell('<%= RadSpell1.ClientID %>').startSpellCheck(); 
        } 
        window.onload = doSpellCheck 
    </script>  
</body>  
</html>  



Thanks!
Steven

2 Answers, 1 is accepted

Sort by
0
Accepted
Martin
Telerik team
answered on 23 Dec 2009, 08:57 AM
Hi Steven D'Anna,

In ASP.NET AJAX it is recommended to use the Sys.Application.load function of the framework instead of JavaScript window.onload function. Although both functions are supposed to execute when page loads, Sys.Application.load function of ASP.NET AJAX handles certain problems that usually arise when window.onload has been used. I suggest that you use Sys.Application.load because it will execute after the controls have been initialized on the page and I believe that you will be able to spellcheck successfully. You may refer to the following article as well:

Sys.Application.load

Kind regards,
Martin Ivanov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Steven D'Anna
Top achievements
Rank 1
answered on 23 Dec 2009, 03:54 PM
That worked like a charm!  Thanks for the response.
Tags
Spell
Asked by
Steven D'Anna
Top achievements
Rank 1
Answers by
Martin
Telerik team
Steven D'Anna
Top achievements
Rank 1
Share this question
or