I am using the winforms web browser control to display some content in a windows forms application. I use the DocumentText property to write the generated HTML. This part works spectacularly. Now I want to use some images in the markup. (I would also prefer to use related CSS and JavaScript, however, this could be handled simply by nesting it.)
I have been working for several days and can not find the answer to the title question.
I tried using a relative link: the exe application is in bin \ debug. Images are in the "Images" directory at the root of the project. I found that the images will be copied to the output directory during compilation, so they get into bin \ debug \ Images *. Therefore, I then use a link similar to this "Samples ...", thinking that it will refer to exe. However, when I look at the image properties in the built-in browser window, I see the image URL "about: blankImages / *". Everything seems to be like "about: blank" when HTML is written to the control. Lack of location context, I cannot figure out what to use relative resource file for linking.
I searched the properties of the control to see if there is a way to set something to fix this. I created an empty html page and pointed the browser to it using the "Navigation" () method, using the full local path to the file. This worked fine with a browser reporting the local path "file: /// ..." to a blank page. Then I wrote the browser again, this time using Document.Write (). Again, the browser now reports "about: blank" as the URL.
Without writing dynamic HTML results to a real file, is there no other way to link to a file resource?
I am going to try the latter: build absolute paths to images and write them in HTML. My HTML is generated using the XSL transform of a serialized XML object, so I will need to play with some XSL parameters, which will require a bit of extra time, as I am not familiar with them.
Peter
source share