locked
Adding an image as a WebResources RRS feed

  • Question

  • User853066379 posted

    Hi,

    I'm trying to add an image to my custom control as a WebResource. I've added the reference to AssemblyInfo.vb and in my control I've done the following:

    Dim str As String = "Contensis.Bespoke.ClassLibrary.star.gif"
    Dim cs As ClientScriptManager = Me.Page.ClientScript
    Dim rstype As Type = GetType(WebControls.PageComments)
                
    Dim img As New Image
    img.ImageUrl = cs.GetWebResourceUrl(rstype, str)
    img.ID = "star"
    img.BorderWidth = 1
    Return img


    When I view my control on a page the image is there but padding of 5px has been added. I've tried setting img.height and img.width and I've also applied a style sheet but this makes no difference. Changing the size of the gif makes no difference either I always have 5px padding around the image.

    Has anyone else seen this or does anyone have a solution?

    Thanks in advance of replies.

    MB

    Tuesday, December 1, 2009 7:11 AM

Answers

  • User853066379 posted

    Thanks for the reply.


    I got round this in the end by applying a style to all images in the containing div i.e.

    .container img{

          padding:0px;

    }

    Instead of applying a class to the image i.e img.cssclass = "myClass".


    It's a bit irritaing that I can't apply styles directly to images that are added as resources so if anyone else has a solution let us know.


    Cheers.




     


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 2, 2009 10:57 AM

All replies

  • User-16411453 posted

    perhaps the image itself has a small 2px margin around it, or the background is not transparent. I doubt if the image has padding around it. Could be cellpadding in the table, or the image doesn't know where to align at, text-align: left, valign, ImageAlign-absmiddle.

    .img.style.add("border", "none")

    I've nver had the problem, but I place images inside containers, and make sure the containers line up correctly with css.


    Tuesday, December 1, 2009 8:30 PM
  • User853066379 posted

    Thanks for the reply.


    I got round this in the end by applying a style to all images in the containing div i.e.

    .container img{

          padding:0px;

    }

    Instead of applying a class to the image i.e img.cssclass = "myClass".


    It's a bit irritaing that I can't apply styles directly to images that are added as resources so if anyone else has a solution let us know.


    Cheers.




     


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 2, 2009 10:57 AM