473,394 Members | 1,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Is it possible to use a embedded resource with WebBrowser?

LEM
Hi,

I use a Webbrowser component to display a page that
has been generate dynamically from my C# program.
This page contains some images that are displayed using
HTML code like this:
<img src="person.gif">

person.gif is an image that is located in my bin folder.

What I would like to do is to use an embedded picture resource
instead, so I don't have to include the picture in my destination
folder.

Is that possible? If it is, what syntax should I use to display an image?

Thanks
Jun 27 '08 #1
6 6451
Your image would be something like this:

string strSrc =
global::YourCustomNamespace.Properties.Resources.N ameOfImageYouLoaded;

Then,
<img src="<%=strSrc>">

(line above is untested. not sure about the placement of quotes and such.)

Hope it helps.

"LEM" wrote:
Hi,

I use a Webbrowser component to display a page that
has been generate dynamically from my C# program.
This page contains some images that are displayed using
HTML code like this:
<img src="person.gif">

person.gif is an image that is located in my bin folder.

What I would like to do is to use an embedded picture resource
instead, so I don't have to include the picture in my destination
folder.

Is that possible? If it is, what syntax should I use to display an image?

Thanks
Jun 27 '08 #2
LEM
Thanks for your help.

Almost there... I get an error at your first line:
Cannot implicitly convert type 'System.Drawing.Bitmap' to 'string'

Not sure if I need to cast something or not.

jp2msft wrote:
Your image would be something like this:

string strSrc =
global::YourCustomNamespace.Properties.Resources.N ameOfImageYouLoaded;

Then,
<img src="<%=strSrc>">

(line above is untested. not sure about the placement of quotes and such.)

Hope it helps.

"LEM" wrote:
>Hi,

I use a Webbrowser component to display a page that
has been generate dynamically from my C# program.
This page contains some images that are displayed using
HTML code like this:
<img src="person.gif">

person.gif is an image that is located in my bin folder.

What I would like to do is to use an embedded picture resource
instead, so I don't have to include the picture in my destination
folder.

Is that possible? If it is, what syntax should I use to display an image?

Thanks
Jun 27 '08 #3
On Jun 11, 12:58*pm, LEM <anonym...@nospam.comwrote:
Hi,

I use a Webbrowser component to display a page that
has been generate dynamically from my C# program.
This page contains some images that are displayed using
HTML code like this:
<img src="person.gif">

person.gif is an image that is located in my bin folder.

What I would like to do is to use an embedded picture resource
instead, so I don't have to include the picture in my destination
folder.

Is that possible? If it is, what syntax should I use to display an image?

Thanks
Hi,

You can extract your images into temp files and then use the temp
paths in your webpage
Jun 27 '08 #4
Ah yes! That would be right.

You won't be able to get a string path to an embedded resource. The code I
showed you will provide you with an embedded resource, but your HTML requires
a string path to a file.

If this were a windows form and you were trying to fill a PictureBox Image,
this would work.

Since you are dealing with HTML, I don't think you can do this.

"LEM" wrote:
Thanks for your help.

Almost there... I get an error at your first line:
Cannot implicitly convert type 'System.Drawing.Bitmap' to 'string'

Not sure if I need to cast something or not.

jp2msft wrote:
Your image would be something like this:

string strSrc =
global::YourCustomNamespace.Properties.Resources.N ameOfImageYouLoaded;

Then,
<img src="<%=strSrc>">

(line above is untested. not sure about the placement of quotes and such.)

Hope it helps.

"LEM" wrote:
Hi,

I use a Webbrowser component to display a page that
has been generate dynamically from my C# program.
This page contains some images that are displayed using
HTML code like this:
<img src="person.gif">

person.gif is an image that is located in my bin folder.

What I would like to do is to use an embedded picture resource
instead, so I don't have to include the picture in my destination
folder.

Is that possible? If it is, what syntax should I use to display an image?

Thanks
Jun 27 '08 #5
Now here is a thought: Instead of linking to some file, you may be able to
drop a PictureBox onto your webform. If so, then in your code, you can assign
the Image using your embedded resources!

Always 2 ways to skin a cat (though I'm not really interested in skinning
any cats).

"LEM" wrote:
Thanks for your help.

Almost there... I get an error at your first line:
Cannot implicitly convert type 'System.Drawing.Bitmap' to 'string'

Not sure if I need to cast something or not.

jp2msft wrote:
Your image would be something like this:

string strSrc =
global::YourCustomNamespace.Properties.Resources.N ameOfImageYouLoaded;

Then,
<img src="<%=strSrc>">

(line above is untested. not sure about the placement of quotes and such.)

Hope it helps.

"LEM" wrote:
Hi,

I use a Webbrowser component to display a page that
has been generate dynamically from my C# program.
This page contains some images that are displayed using
HTML code like this:
<img src="person.gif">

person.gif is an image that is located in my bin folder.

What I would like to do is to use an embedded picture resource
instead, so I don't have to include the picture in my destination
folder.

Is that possible? If it is, what syntax should I use to display an image?

Thanks
Jun 27 '08 #6
try navigating to

res://ApplicationPath/ApplicationName.exe/myembeddedresourcename.png

--
Pete
=========================================
I use Enterprise Core Objects (Domain driven design)
http://www.capableobjects.com/
=========================================
Jun 27 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Leonardo D'Ippolito | last post by:
Hello sirs, I have a project for a .DLL in .NET that has an XML file as embedded resource. Is it possible to update/substitute this embedded resource in the DLL without having to re-compile the...
0
by: dragan | last post by:
I want to display HTML file as an embedded resource, (read it into MS webBrowser control.) I also have pictures in HTML file. My problem is that I dont want users to be able to copy text in...
1
by: james | last post by:
What class / method should I be using to get the full path to an embedded resource ? In my case I have an .xml file that my app uses, it is set as embedded resource, and I have a control that...
5
by: Drew | last post by:
Assembly asm = Assembly.GetExecutingAssembly(); me = new Bitmap(asm.GetManifestResourceStream("me.gif")); I have used this before without any problem, but now I get: An unhandled exception...
2
by: Kyle Kaitan | last post by:
I have an assembly (AppResources.dll) which contains a number of embedded resource files. Most of these are key/value pairs of relevant strings; a few are images and sounds; some more are XML...
4
by: Jason Pettys | last post by:
In an ASP.NET project I am setting the content type of my .ascx and ..aspx files to Embedded Resource for a separate reason. When I do this they get embedded as "RootNamespace.Filename" but I...
1
by: photochop | last post by:
I know the question of whether or not a SWF file can be read in by a ..NET application has been asked a billion times, however, what I'm asking is whether or not it is possible (any examples?...
4
by: Jeremy Chapman | last post by:
I'b developing a web app to be viewed on various mobile devices, and I want the app to be as light as possible. I noticed that some of my pages have a link to the embedded resource webforms.js in...
2
by: FishingScout | last post by:
I have a small html file that I have added to my project. When I added "sample.html", I set the build action to "embedded resource". In the application I would like to do something like this (...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.