Last post Dec 02, 2009 10:57 AM by m_b
Dec 01, 2009 07:11 AM|m_b|LINK
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
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.
Dec 01, 2009 08:30 PM|jkirkerx|LINK
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.
I've nver had the problem, but I place images inside containers, and make sure the containers line up correctly with css.
Dec 02, 2009 10:57 AM|m_b|LINK
Thanks for the reply.
I got round this in the end by applying a style to all images in the containing div i.e.
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.