OnClientLoad Event is not defined

2 posts, 0 answers
  1. Ritika
    Ritika avatar
    6 posts
    Member since:
    Oct 2012

    Posted 01 Nov 2012 Link to this post

    Hi,

    I am trying to attach onkeypress eventhandler in onclientload of radeditor. I want to check a checkbox as soon as any alphabet is entered in radeditor.

    <telerik:RadEditor runat="server" ID="RadEditor1" ContentAreaMode="Div" EditModes="Design" 
                                     OnClientLoad="OnClientLoad">

    <script type="text/javascript">
         function OnClientLoad(editor) {
                editor.AttachEventHandler("onkeypress", function (e) {
                    $('#<%=chktext.ClientID %>').attr('checked', true);
                });
            }
    </script>

    i get a javascript error which says UnCaught Reference Error:OnClientLoad is not defined. What should i do?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 01 Nov 2012 Link to this post

    Hi Ritika,

    Try the following code snippet to achieve your scenario.

    ASPX:
    <telerik:RadEditor runat="server" ID="RadEditor1" ContentAreaMode="Div" EditModes="Design" OnClientLoad="OnClientLoad">
    </telerik:RadEditor>
    <asp:CheckBox ID="chktext" runat="server" />

    JS:
    <script type="text/javascript">
        function OnClientLoad(editor) {
            editor.attachEventHandler("onkeypress", function (e) {
                $('#<%=chktext.ClientID %>').attr('checked', true);
            });
        }
    </script>

    Hope this helps.

    Regards,
    Shinu.
Back to Top