Re: populating the editor via listbox c#/javascript, how to refernce the textareas ID

  •  01-13-2011, 2:44 PM

    Re: populating the editor via listbox c#/javascript, how to refernce the textareas ID

    Dear AWilderbeast,
     
    Please refer to the following code:
     
    Default5.aspx:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="Default5" %>
    <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
    <!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 runat="server">
        <title></title>
        <script type="text/javascript">
            function setContent() {          
                // get the cute editor instance
        var editor1 = document.getElementById('<%=Editor1.ClientID%>');    
        editor1.setHTML("this is a test");
             }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
       <table>
       <tr>
       <td>
        <asp:ListBox ID="FieldsList"  runat="server" rows="20" width="200px" 
                >        
                        </asp:ListBox>
       </td>
       <td>
         <CE:Editor id="Editor1"  ThemeType="Office2007" EditCompleteDocument="true" AllowPasteHtml="false" runat="server" ></CE:Editor><BR>
     
       </td>
       </tr>
      
       </table>
        </div>
        </form>
    </body>
    </html>
     
    Default5.aspx.cs:

    using System;
    using System.Collections.Generic;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public partial class Default5 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Dictionary<string, string> list = new Dictionary<string, string>();
         
            list.Add("1", "Please Select a Category1");
            list.Add("2", "Please Select a Category2");
            list.Add("3", "Please Select a Category3");
            list.Add("4", "Please Select a Category4");
            FieldsList.DataSource = list;
            FieldsList.DataTextField = "Value";
            FieldsList.DataValueField = "Key";
            FieldsList.DataBind();
            // FieldsList.Attributes.Add("ondblclick", "document.forms[0]['" + TextBox1.ClientID + "'].value += " + ListItem);
            //FieldsList.Attributes.Add("ondblclick", 'BLOCKED SCRIPTreturn confirm(‘Are you sure to save?’);');
             FieldsList.Attributes.Add("ondblclick","j avascript:setContent();");       }
       }


    Thank you for asking
View Complete Thread