Click here to Skip to main content
12,631,231 members (31,073 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: .NET .NET4
We need to embed an image in an html document, in C# or VB code. The document will be saved in a database, so it must be free of any file references. I have been researching this for a day or so, and cannot find anything complete. I would like to know if anyone has a step by step process for doing this.
Posted 19-Feb-13 12:43pm
Comments
Sergey Alexandrovich Kryukov 19-Feb-13 18:21pm
   
Why? <img src="..."/> will be more compact.
—SA
BobishKindaGuy 19-Feb-13 19:02pm
   
The document will be saved in a database, so it must be free of any file references.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Is this[^] what you are looking for?
  Permalink  
Comments
Sergey Alexandrovich Kryukov 19-Feb-13 18:19pm
   
Nice, a 5. (I suspect OP's question is simpler... who knows?)
—SA
Wonde Tadesse 19-Feb-13 20:36pm
   
5+
BobishKindaGuy 19-Feb-13 21:40pm
   
Thanks Marcus, your suggestion goes to a page that works, but with a tool.
I found Zoltán's reference, located some base64 encoder code, (http://www.codeproject.com/Articles/5483/Base64-Encoder-Decoder-in-C), and converted it to VB. So far I can save the html doc in a database field and retrieve it, whereupon it appears as an image, so I think with a few more tweaks I'll be fine. Next task will be attachments, same goal.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

There is a way, by using base64 encoding, see this article: http://www.bigfastblog.com/embed-base64-encoded-images-inline-in-html[^]
But I am not sure if there is any size limit, or what is the browser support coverage.

What you might also consider is storing mht's which are also self-contained. A starting point ó could be this article: http://mycsharpcorner.blogspot.hu/2011/01/create-mht-from-html-in-c.html[^]
  Permalink  
v2
Comments
Sergey Alexandrovich Kryukov 19-Feb-13 18:20pm
   
Sure it works, a 5.
—SA
Wonde Tadesse 19-Feb-13 20:36pm
   
5+
BobishKindaGuy 19-Feb-13 21:42pm
   
Thanks Zoltán!
I located some base64 encoder code, (http://www.codeproject.com/Articles/5483/Base64-Encoder-Decoder-in-C), and converted it to VB. So far I can save the html doc in a database field and retrieve it, whereupon it appears as an image, so I think with a few more tweaks I'll be fine. Next task will be attachments, same goal.
Zoltán Zörgő 20-Feb-13 3:25am
   
If you need attachments too, I suggest you switch to something else, like mht or pdf. You need a self-contained document format, html is not one.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161205.3 | Last Updated 19 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100