CuteEditor for .NET

Code Snippet Dropdown Customization

Code Snippet Dropdown Customization


The Code Snippet Dropdown of CuteEditor by default displays a predefined set of Code Snippets. You can easily modify this default set using the following methods:

1: Edit Dropdown Configuration file (Common.config):

The dropdown configuration file (Common.config) can be found in the /CuteEditor/Configuration/Shared folder. In dropdown configuration file you can find the Codes element which contains the configuration information for the Code Snippet dropdown within CuteEditor. 

You can modify the Codes element to create your own Code Snippet list.

Example:


 <Codes>

       <item text="Email signature">

                  <value><![CDATA[
                                              
                ''~``<br />
                                       
                        ( o o )<br />
                             
+------------------.oooO--(_)--Oooo.---------------------+<br />
                             
| John Smith                                                            |<br />
                              |
                       E-mail: <a href="mailto:fake-company@server.com">fake-company@server.com</a>
                           
  |<br />
                             
| Fake Company          <a href="http://www.fake-company.com/">http://www.fake-company.com/</a>     |<br />
                             
| Ottawa, Canada     (   )                               |<br />
                              
+---------------------\ (----(   )-----------------------+<br />
                             
                       \_)    ) /<br />
 
                             (_/
                           
]]>
                </value>

                  <html>
                           <![
CDATA[

                                 <img border=0 align='absMiddle' src='http://cutesoft.net/data/signature.gif' /> Email signature

                           ]]>

                 </html>

     </item>

     <item text="Contact us">

               <value><![CDATA[
                              <div
>Your satisfaction is necessary to our success. Our goal is to provide you with the best level of customer service, and we welcome 
                               your  comments and suggestions<br /><br />
                               <
strong>Email:<br /><br /></strong>Sales: <a href="mailto:sales@CuteSoft.Net">sales@CuteSoft.Net</a>

                               <br /><br />
                               
General: <a href="mailto:info@CuteSoft.Net">info@CuteSoft.Net</a><br /><br />
                              
Support: <a href="mailto:support@CuteSoft.Net">support@CuteSoft.Net < /a><br />

                               <strong><br /> Address:</strong><br /><br />
                               
CuteSoft<br />
                               
35 SHERWOOD CRES<br />
                              
BELLEVILLE, ON<br />
                              
K8P 5G2<br />
                             
Canada </div>
                      
]]>
              </value>

              <html><![CDATA[
                             <img border=0
align='absMiddle' src='http://cutesoft.net/data/contact.gif' /> Contact us
                        ]]>
            </html>

     </item>

</Codes>

Now the Code Snippet dropdown contains the followings:




 

 


2: Programmatically populate the Code Snippet dropdown:

C# Example:

if (!IsPostBack) { 
CuteEditor.ToolControl toolctrl=Editor1.ToolControls["Codes"];
if(toolctrl!=null) {
CuteEditor.RichDropDownList dropdown=(CuteEditor.RichDropDownList)toolctrl.Control;
//the first item is the caption
CuteEditor.RichListItem richitem=dropdown.Items[0];
//clear the items from configuration files
dropdown.Items.Clear();
//add the caption
dropdown.Items.Add(richitem);
//add text and value
dropdown.Items.Add("Email signature","<h3>this is my email signature</h3>");
//add html and text and value
dropdown.Items.Add("<img border=0 align='absMiddle' src= 'http://cutesoft.net/data/contact.gif'/> Contact us","Contact us","support@cutesoft.net");
}
}


VB Example:

If Not Page.IsPostBack Then
  If Not Editor1.ToolControls("Codes") Is Nothing Then

      Dim dropdown As CuteEditor.RichDropDownList
      Dim richitem As CuteEditor.RichListItem

      dropdown = DirectCast(Editor1.ToolControls("Codes").Control, CuteEditor.RichDropDownList)

      'the first item is the caption
      richitem = dropdown.Items(0)

      'clear the items from configuration files
      dropdown.Items.Clear()

      'add the caption
      dropdown.Items.Add(richitem)

     'add text and value
      dropdown.Items.Add("Email signature","<h3>this is my email signature</h3>")

      'Add html and text and value
      dropdown.Items.Add("<img border=0 align='absMiddle' src= 'http://cutesoft.net/data/contact.gif'/> Contact us", "Contact us", "support@cutesoft.net")

  End If
End If