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

Last post 08-10-2005, 12:26 PM by richardm. 5 replies.
Sort Posts: Previous Next
  •  08-09-2005, 10:40 AM 9400

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

    When I run this code:
          Dim dropdown As CuteEditor.RichDropDownList
          dropdown = DirectCast(objEditor.ToolControls("Links").Control, CuteEditor.RichDropDownList)

    I get this error:
          System.InvalidCastException: Specified cast is not valid

    Has anyone else had this problem? - The code is taken directly from the documentation.

    [Using CuteEditor v4.5; and "links" does exist in the collection]
  •  08-09-2005, 11:17 AM 9403 in reply to 9400

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

    Please try the following code:
     
    Dim dropdown As CuteEditor.TreeDropDownList dropdown = DirectCast(objEditor.ToolControls("Links").Control, CuteEditor.TreeDropDownList)
     

    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

  •  08-09-2005, 11:45 AM 9408 in reply to 9403

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

    Thanks for your swift response -- unfortunately even with the change I get the same error,
           Specified cast is not valid.
    Although if viewed as a QuickWatch in the debugger it says
            Cannot convert to 'Class TreeDropDownList'.   

    If you have any more thoughts I would be much obliged..
  •  08-09-2005, 12:00 PM 9411 in reply to 9408

    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

  •  08-09-2005, 12:33 PM 9412 in reply to 9411

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

    I'll try this out tomorrow! -- Many thanks --
  •  08-10-2005, 12:26 PM 9458 in reply to 9412

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

    worked like a dream -- cheers for your speedy responses.
View as RSS news feed in XML