More in this section

Forums / Developing with Sitefinity / Toolbox error when adding Custom Control

Toolbox error when adding Custom Control

5 posts, 1 answered
  1. Michael
    Michael avatar
    32 posts
    Registered:
    14 Jan 2010
    09 Feb 2010
    Link to this post
    Hello,

    I've come across an error when attempting to add my Custom Control to the sitefinity toolbox which is the following - Unable to cast object of type 'CustomSearchResults.CustomSearchBoxToolboxItem' to type 'System.Drawing.Design.ToolboxItem'. I've found and follwed the steps in the following forum thread (Uploading Custom DLL),  but still haven't been able to resolve it yet.

    So far I have a CustomSearchResult DLL, which contains the following namespace and class

    using Telerik.Lists.PersistentObjects;
      
      
    namespace CustomSearchResults
    {
        #region Search Result
        [ToolboxItem(typeof(CustomSearchBoxToolboxItem))]
        public class CustomSearchResult : SearchResult
        {

    in the same code file I also have the following toolbox entry

    public class CustomSearchBoxToolboxItem : ToolboxItem
        {
            public CustomSearchBoxToolboxItem()
                : base(typeof(CustomSearchResult))
            {
                base.DisplayName = "Test";
                base.Description = "Test Search Control";
            }
      
        }

    And finally I have the following entry in the web.config file.

    <add name="Test" section="Custom" type="CustomSearchResults, bin" />

    The CustomSearchResults.DLL is held within the sites bin folder which is where I've pointed the web.config file.

    If anyone could tell me where I'm going wrong it would be appreciated.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    09 Feb 2010
    Link to this post
    Hi Michael Gamlin,

    The following line is not correct

    <add name="Test" section="Custom" type="CustomSearchResults, bin" />

    the syntaxis is type="CLASS NAME, Assembly"

    The namespace of ToolboxItem is Telerik.Web. Make sure that you are referring  Telerik.Web.ToolboxItem


    Regards,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  3. Michael
    Michael avatar
    32 posts
    Registered:
    14 Jan 2010
    09 Feb 2010
    Link to this post
    I changed the code you pointed out and sorted that, although I've had no luck with the toolbox. I double checked and my CustomSearchBoxToolBoxItem is inheriting from Telerik.Web.ToolboxItem and hardcorded that in to be sure.

    Does the Toolbox class have to be in a different code file? As I currently have both the CustomSearchResult and toolbox in the same file.

    If you require more of my code please let me know.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    09 Feb 2010
    Link to this post
    Hello Michael Gamlin,

    Try using System.Drawing.Design.ToolboxItem. You can separate the toolbox in another file and reference it in your custom search box.

    [ToolboxItem(typeof(CustomSearchBoxToolboxItem))]


    Regards,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
    Answered
  5. Michael
    Michael avatar
    32 posts
    Registered:
    14 Jan 2010
    10 Feb 2010
    Link to this post
    Thanks for the support, I've got it working now.

    Just need to work on the rest lol.
Register for webinar
5 posts, 1 answered