locked
CKEditor not working properly in Listview Control RRS feed

  • Question

  • User-1754966503 posted

    I have used CKEditor in Insert item template and Edit Item Template in List view, for this i have used a textbox <o:p></o:p>

    <asp:TextBox ID="txtComment" runat="server" TextMode="MultiLine" Text='<%# Bind("CommentDescription") %>'></asp:TextBox><o:p></o:p>

    <script type="text/javascript"> <o:p></o:p>

    CKEDITOR.replace(document.getElementById('<%=txtComment.ClientID%>').value, { height: '100px', width: '100%' });<o:p></o:p>

    </script><o:p></o:p>

     here i am suppose to provide the client id of the textbox to CKEDITOR.replace but belowstatement gives me error -"The name 'txtComment' does not exist in the current context"
    CKEDITOR.replace(document.getElementById(
    '<%=txtComment.ClientID%>').value, { height: '100px', width: '100%' });<o:p></o:p>

    the control id for every control placed in list view keeps changing on any insert or delete operation performed on listview control at runtime, becoz of which i am unable to bind the textbox to CKEditor, i also tried to bind the CKEditor to textbox in listview's Databound Event like this:<o:p></o:p>

    TextBox CKInsertComment = (TextBox)lvSender.InsertItem.FindControl("txtComment");<o:p></o:p>

    String script = string.Empty;<o:p></o:p>

    script = Random rand = new Random(1);<o:p></o:p>

    @"CKEDITOR.replace('" + CKInsertComment.ClientID + "',{height:\"100px\",width:\"100%\"});";ScriptManager.RegisterStartupScript(this, this.GetType(), "CKeditorAdd1111" + rand.Next().ToString(), script, true);<o:p></o:p>

    but this also gives me error after some clicks, please help if anyone has tried useing CKEditor in ListView Control.<o:p></o:p>

    Friday, April 16, 2010 5:13 AM

All replies