Re: 'Specified cast is not valid' when adding a dropdown item...

  •  08-09-2005, 12:00 PM

    Re: 'Specified cast is not valid' when adding a dropdown item...

    Please check this example:
     
     
    You can find the source code of the above example in the download package.
     
    If Not Editor1.ToolControls("insertcustombutonhere") Is Nothing Then
    
    
                    Dim container As System.Web.UI.Control
    
                    container = Editor2.ToolControls("insertcustombutonhere").Control
    
                    Dim dropdown As CuteEditor.RichDropDownList
    
                    dropdown = New CuteEditor.RichDropDownList(Editor2)
    
                    'set the onchange statement
                    'use the CuteEditor_DropDownCommand => editor.ExecCommand('InsertLink',false,ddl.value)
                    dropdown.Attributes("onchange") = "CuteEditor_DropDownCommand(this,'InsertLink')"
    
                    'must set this css name
                    dropdown.CssClass = "CuteEditorDropDown"
    
                    'add the first item (caption)
                    'the culture-text would be auto replaced..
                    dropdown.Items.Add("[[Links]]", "")
    
                    'hide the first item (caption) in the float-panel
                    dropdown.RichHideFirstItem = True
    
                    'add the items here every times
                    dropdown.Items.Add("http://www.asp.net/")
    
                    'add - !!!
                    'if the statements put before Controls.Add , the statements must be executed every time
                    container.Controls.Add(dropdown)
                    'if the statements put after Controls.Add the statements could be executed only the first time
    
                    'or add items here if(!IsPostBack)
                    If Not Page.IsPostBack Then
                        dropdown.Items.Add("Microsoft", "http://www.microsoft.com/")
                        dropdown.Items.Add("<font color=red>CuteSoft</font>", "*CuteSoft*", "http://www.cutesoft.net/")
                    End If
    
                End If

    Keep me posted.
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

View Complete Thread