code to drop an image from images dropdown

Last post 04-14-2010, 10:35 AM by oompah. 6 replies.
Sort Posts: Previous Next
  •  03-06-2008, 11:39 AM 37642

    code to drop an image from images dropdown

    Hi! is there a sample code on how to drop an images from the images fropdown. Thanks!
  •  03-06-2008, 12:47 PM 37645 in reply to 37642

    Re: code to drop an image from images dropdown

  •  04-13-2010, 5:36 PM 60071 in reply to 37645

    Re: code to drop an image from images dropdown

    I am trying to use the code to do it programtically but no matter what I do it still leaves your default logo and flower image in there.
     
    I assume programtically setting this I do not need to edit the Common.config file or do i need to do both
     
    here is my code
     
     
    Dim dropdown As CuteEditor.RichDropDownList
                Dim richitem As CuteEditor.RichListItem
                dropdown = DirectCast(cutefile.ToolControls("Images").Control, CuteEditor.RichDropDownList)
                richitem = dropdown.Items(0)
                dropdown.Items.Clear()
                dropdown.Items.Add(richitem)
                dropdown.Items.Add("Welcome", "<img src=" & Chr(34) & "images/Title-Welcome.gif" & Chr(34) & " alt=" & Chr(34) & "" & Chr(34) & " />")
     
    I also tried replaceing the chr(34) in the alst line with a single apostrophe - you can not put a double quote in there in vb it will cause a non valid string compiler error - you may want to alter that in the help file you referenced above.
     
    Please advise
     
     
     
     
  •  04-13-2010, 5:46 PM 60072 in reply to 60071

    Re: code to drop an image from images dropdown

    I am using version 6.6
  •  04-14-2010, 12:00 AM 60077 in reply to 60071

    Re: code to drop an image from images dropdown

    oompah:
    I am trying to use the code to do it programtically but no matter what I do it still leaves your default logo and flower image in there.
     
    I assume programtically setting this I do not need to edit the Common.config file or do i need to do both
     
    here is my code
     
     
    Dim dropdown As CuteEditor.RichDropDownList
                Dim richitem As CuteEditor.RichListItem
                dropdown = DirectCast(cutefile.ToolControls("Images").Control, CuteEditor.RichDropDownList)
                richitem = dropdown.Items(0)
                dropdown.Items.Clear()
                dropdown.Items.Add(richitem)
                dropdown.Items.Add("Welcome", "<img src=" & Chr(34) & "images/Title-Welcome.gif" & Chr(34) & " alt=" & Chr(34) & "" & Chr(34) & " />")
     
    I also tried replaceing the chr(34) in the alst line with a single apostrophe - you can not put a double quote in there in vb it will cause a non valid string compiler error - you may want to alter that in the help file you referenced above.
     
    Please advise
     
     
     
     
     
    Hi oompah,
     
    Try this example
     
    1. <%@ Page Language="VB" %>   
    2.   
    3. <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>   
    4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
    5.   
    6. <script runat="server">   
    7.     Protected Overloads Overrides Sub OnLoad(ByVal e As EventArgs)   
    8.         If Not IsPostBack Then  
    9.             Dim toolctrl As CuteEditor.ToolControl = editor1.ToolControls("Images")   
    10.             If toolctrl IsNot Nothing Then  
    11.                 Dim dropdown As CuteEditor.RichDropDownList = DirectCast(toolctrl.Control, CuteEditor.RichDropDownList)   
    12.                 'the first item is the caption    
    13.                 Dim richitem As CuteEditor.RichListItem = dropdown.Items(0)   
    14.                 'clear the items from configuration files    
    15.                 dropdown.Items.Clear()   
    16.                 'add the caption    
    17.                 dropdown.Items.Add(richitem)   
    18.                 'add text and value    
    19.                 dropdown.Items.Add("Logo""<img src='Uploads/10n2.jpg'/>")   
    20.                 'add html and text and value    
    21.                 dropdown.Items.Add("<img src='Uploads/12.jpg' /> ""Flower""<img src='Uploads/12.jpg'/>")   
    22.             End If  
    23.         End If  
    24.         MyBase.OnLoad(e)   
    25.     End Sub  
    26. </script>   
    27.   
    28. <html xmlns="http://www.w3.org/1999/xhtml">   
    29. <head runat="server">   
    30.     <title>Untitled Page</title>   
    31. </head>   
    32. <body>   
    33.     <form id="form1" runat="server">   
    34.         <div>   
    35.             <CE:Editor ID="editor1" runat="server">   
    36.             </CE:Editor>   
    37.         </div>   
    38.     </form>   
    39. </body>   
    40. </html>  
    Regards,
     
    Ken
  •  04-14-2010, 10:11 AM 60089 in reply to 60077

    Re: code to drop an image from images dropdown

    this line
     

    Dim dropdown As CuteEditor.RichDropDownList = DirectCast(toolctrl.Control, CuteEditor.RichDropDownList)

     
    causes an catastrophic error - not even a .net error but forces the site either display a blank markup or to render a 404 error.  I dimmed out all code except yours and one by one undimmed lines, so this line is the culprit.
     
    I am using asp.net 3.5 and using visual studio 2008 to develop in - not sure if I mentioned that prior or if I even erroneously said i was using asp.net 2.0 but it is definitely .net 3.5
     
    regards.
  •  04-14-2010, 10:35 AM 60091 in reply to 60077

    Re: code to drop an image from images dropdown

    ok I figured it out
     
    the code on the site Adam linked to originally works fine, but you have to be careful in which what order you issue commands to alter the cute editor programtically.
     
    I created helper functions to step through management of the cute editor - the code snippets and images drop down only work when called last in the sequence.
     
    I will publish my helper files and source code once it's smoothed out a bit - it is unfortunately vb only though - I would imagine the community at large might find some benefit.
View as RSS news feed in XML