Custom Control with embedded graphic

  • Thread starter Dave Birchok via .NET 247
  • Start date
D

Dave Birchok via .NET 247

I am developing a custom control for web forms using VS 2003. Iam putting the control in a custom control library project whichwill become a dll. This control uses a small bitmap. I don'twnat to have to copy the graphic file into each web project thatwill use this custom control. VS allows you to set the graphicfile's build action property to embedded resource. When thecustom control renders it will create HTML that I would like toreference the embedded graphic file. Is this possible?

Thanks,
 
V

Victor Garcia Aprea [MVP]

Hi Dave,

Yes its possible. The most common approach is to write a handler to serve
embedded images from assemblies. ASP.NET's next version will have built-in
support for this. You can take a look at this article[1] which contains
enough info and detail about how it works and so it should serve as a
jumpstart for your own implementation in ASP.NET 1.x

[1]
http://msdn.microsoft.com/asp.net/c...ll=/library/en-us/dnaspp/html/webresource.asp

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup

I am developing a custom control for web forms using VS 2003. I am putting
the control in a custom control library project which will become a dll.
This control uses a small bitmap. I don't wnat to have to copy the graphic
file into each web project that will use this custom control. VS allows you
to set the graphic file's build action property to embedded resource. When
the custom control renders it will create HTML that I would like to
reference the embedded graphic file. Is this possible?

Thanks,
 
A

Andrei Sinelnikov

Here is one way of retrieving embedded resource.
I don't know though how you can apply it to image. But I think that
this is possible.

' Retrieving XML-file from the embedded resources.
Dim thisExe As System.Reflection.Assembly
thisExe = System.Reflection.Assembly.GetExecutingAssembly()
' Replace "AssemblyName.FileName.xml" with the name of the
resource, as it is known in the assembly.
' Use the GetManifestResourceNames method of the Assembly
object to find the resource name.
Dim strFileName As System.IO.Stream = _
thisExe.GetManifestResourceStream("<Type Accembly Name
Here>.Reports.xml")
' Read XML.
Dim doc As XmlDocument = New XmlDocument()
doc.Load(strFileName)


WBR,
Andrei
 
F

Fred Hirschfeld

I have a complete code for this if you would like... The last remaining part
of this is how do I use the embedded graphics at design-time? I know I could
create a custom designer for this, but is there any other way?

Fred

I am developing a custom control for web forms using VS 2003. I am putting
the control in a custom control library project which will become a dll.
This control uses a small bitmap. I don't wnat to have to copy the graphic
file into each web project that will use this custom control. VS allows you
to set the graphic file's build action property to embedded resource. When
the custom control renders it will create HTML that I would like to
reference the embedded graphic file. Is this possible?

Thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top