Passing Parameters to OnClientLoad event of RadEditor

2 posts, 0 answers
  1. Navnit
    Navnit avatar
    8 posts
    Member since:
    Oct 2012

    Posted 29 Jan 2013 Link to this post

    Hi,

    I am having a requirement where I need to AutoSave RadEditor content. Now these RadEditor are present inside Repeater control and they may be more than one RadEditor present inside the control.

    I have Implemented AutoSave using OnClientLoad event & RadAjaxManager. But the issue here is that I cannot explicitly pass the RadEditor Primary Key id through which I can Identify that the passed RadEditor text on server Side, Since OnClientLoad event doesnot takes any parameters.

    Below is my ASPX Code
    <asp:Repeater ID="Repeater1" runat="server">
        <ItemTemplate>
            <table>
                <tr>
                    <td>
                        <b><asp:Label ID="lblID" Text='<%# DataBinder.Eval(Container.DataItem, "ID")%>' runat="server"
                                Visible="false"></asp:Label></b>
                        <telerik:RadEditor ID="RadEditor1" Content='<%# Bind("Description") %>' runat="server"
                            OnClientLoad="OnClientLoad">
                            <Languages>
                                <telerik:SpellCheckerLanguage Code="en-US" Title="English" />
                            </Languages>
                        </telerik:RadEditor>
                    </td>
                </tr>
            </table>
        </ItemTemplate>

    and my JavaScript Code
    var timer = null;
    var radE = null;
     
    function OnClientLoad(editor, args) {
                    radE = editor;
                    editor.add_spellCheckLoaded(function () {
                        var spell = editor.get_ajaxSpellCheck();
                        spell.add_spellCheckStart(function (editor, args) {
                            stopTimer();
                        });
     
                        spell.add_spellCheckEnd(function (editor, args) {
                            startTimer();
                        });
                    }
                );
                    editor.attachEventHandler("onkeyup", function (e) {
                        stopTimer();
                        startTimer();
                    });
                }
     
    function stopTimer() {
                    if (timer != undefined || timer != null) clearTimeout(timer);
                }
     
                function startTimer() {
                    timer = setTimeout("autoSave()", 6000);
                }
     
    function autoSave() {
                    var content = radE.get_html(true);
                    var ajaxManager = $find("<%= RadAjaxManager.ClientID %>");
                    ajaxManager.ajaxRequest(content);
                   
                }

    Now as OnClientLoad doesn't takes any parameter on server side I cannot identify which Radeditor content is being edited.
     Can you please suggest me any way by which I can pass Label lblID to OnCLientLoad Event of Radeditor.

  2. Navnit
    Navnit avatar
    8 posts
    Member since:
    Oct 2012

    Posted 30 Jan 2013 Link to this post

    Hi,

    I am able to find the workaround for the above. Thanks.
Back to Top