473,789 Members | 2,746 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6488
Your image would be something like this:

string strSrc =
global::YourCus tomNamespace.Pr operties.Resour ces.NameOfImage YouLoaded;

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::YourCus tomNamespace.Pr operties.Resour ces.NameOfImage YouLoaded;

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...@nosp am.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::YourCus tomNamespace.Pr operties.Resour ces.NameOfImage YouLoaded;

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::YourCus tomNamespace.Pr operties.Resour ces.NameOfImage YouLoaded;

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/myembeddedresou rcename.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
1362
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 project? Thanks in advance, Leonardo
0
3553
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 that file or edit it. (already forbiden right or left click on control). When I install my program user can go to
1
24180
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 needs to load it, but I do not want to hard code the path since that may change for different installs. i.e. GetPathForResourceOfName ( myResourceFileName ) thanks, JIM
5
8232
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 of type 'System.ArgumentException' occurred in system.drawing.dll Additional information: 'null' is not a valid value for 'stream'.
2
1895
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 files. My application will load the resources into memory as they are needed. I would like to be able to read and write to these embedded resources. Is it possible to write to an embedded resource within an assembly? If so, how? If it's not...
4
4430
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 would like them to be embedded as "RootNamespace.Folder.Filename". I see that the .resources files are embedded with the containing folder information in the namespace, and I think c# projects work this way, too. Is there any way (a vbc command...
1
2966
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? tutorials? Flash Object COM readme?) to embed a SWF file into your VS.NET project as a resource, and then read in the file into the Flash object much the same way that you currently do using the LoadMovie function that takes in a layer and a file...
4
2874
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 the rendered page. Is this javascript required, and how can I turn it off?
2
7398
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 ( but this doesn't work ): WebBrowser.Navigate( "MyApplication.Sample.html" ) Does anyone know if
0
9666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10408
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10199
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3700
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.