locked
Server Control Icon. ToolboxBitmap not working RRS feed

  • Question

  • User328595291 posted

    I have the following code: (the icon is in the solution root directory)

    [DefaultProperty("LogoPath")]
        [ToolboxData("<{0}:LogoControl runat=server></{0}:LogoControl>")]
        [ToolboxBitmap(typeof(LogoControl),"eye.bmp")]
        public class LogoControl : WebControl
        {

    For some reason I dont get the embbeded icon to work. I've already setted the Build property to Embbeded resource, but the default icon still appears when I import it in the toolbox.

     

    Tuesday, January 31, 2012 8:42 AM

Answers

  • User-1226263862 posted

    Guess I may have been wrong, take a look here: http://msdn.microsoft.com/en-us/library/ie/yhzc935f.aspx specifically the section Specifying an Icon for the Toolbox, the directions are a bit different than I mentioned.  What I mentioned works for images being used within the control itself but not the toolbox images.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 31, 2012 10:34 AM
  • User328595291 posted

    Hey b471code3, I finally solved it.

    The core problem is: the image must have the same name as the user control class! And it has to be BMP!

    So, I followed your link http://msdn.microsoft.com/en-us/library/ie/yhzc935f.aspx (it isn't necessary to set anything in AssemblyInfo.cs).

    I renamed my image to LogoControl.bmp, setted the class attribute

    [Designer("MyServerControls.LogoControlDesigner, MyServerControls")]
        public class LogoControl : WebControl

    , created the ResourceFinder class (I dont know why)

    internal sealed class ResourceFinder
        {
        }

    and corrected the name of my Namespace.

    It worked. Thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 31, 2012 11:07 AM

All replies

  • User-1226263862 posted

    Have you added the resource to the AssemblyInfo.cs file as well?  You should have this line in there:

    [assembly: System.Web.UI.WebResource("YourNameSpace.img.calendar.jpg", "img/jpg")]

    My calendar.jpg image is located in the /img/ directory.  So if your namespace is CustomControl and your image is located in the images directory your entry would look like so: 

    [assembly: System.Web.UI.WebResource("CustomControl.images.eye.jpg", "img/jpg")]

     Then you reference it in code like so: 

    [ToolboxBitmap(typeof(LogoControl),"CustomControl.images.eye.jpg")]

     

    Tuesday, January 31, 2012 8:53 AM
  • User328595291 posted

    HUmmm, good.

    AssemblyInfo.cs:

     

    System.Web.UI.WebResource("MyServerControls.eye.bmp", "image/bmp")]

     

    I've done in LogoControl.cs: 

     

    [ToolboxBitmap(typeof(LogoControl), "MyServerControls.eye.bmp")]
        public class LogoControl : WebControl
        

     

    My image is in MyServerControls -> eye.bmp

    Didn't work yet. I saw some posts saying to check out the MANIFEST, using ILDASM, in order to find out if the image is actually there. Well, there's nothing about my image there.

    Tuesday, January 31, 2012 9:05 AM
  • User-1226263862 posted

    Guess I may have been wrong, take a look here: http://msdn.microsoft.com/en-us/library/ie/yhzc935f.aspx specifically the section Specifying an Icon for the Toolbox, the directions are a bit different than I mentioned.  What I mentioned works for images being used within the control itself but not the toolbox images.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 31, 2012 10:34 AM
  • User328595291 posted

    Hey b471code3, I finally solved it.

    The core problem is: the image must have the same name as the user control class! And it has to be BMP!

    So, I followed your link http://msdn.microsoft.com/en-us/library/ie/yhzc935f.aspx (it isn't necessary to set anything in AssemblyInfo.cs).

    I renamed my image to LogoControl.bmp, setted the class attribute

    [Designer("MyServerControls.LogoControlDesigner, MyServerControls")]
        public class LogoControl : WebControl

    , created the ResourceFinder class (I dont know why)

    internal sealed class ResourceFinder
        {
        }

    and corrected the name of my Namespace.

    It worked. Thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 31, 2012 11:07 AM