.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

Web Browser control will not displaying image

Posted By: Dhilip.R     Posted Date: June 14, 2011    Points:5   Category :C#
Hi,

I have a web browser control that have to display some images int that but the problem is the image is not showing in the web browser.

I used to give the source of the image is base64 string. i used the code like the following

//Inserting image to web browser
public void InsertFile(string path)
{
Bitmap bmp = new Bitmap(getfileWithIcon(path));
string filetype = path.Substring(path.LastIndexOf(@"\") + 1);
string base64Str = ImageToBase64(bmp, System.Drawing.Imaging.ImageFormat.Jpeg);
string htm = "<a><img Height=\"" + bmp.Height.ToString() + "\" src=\"data:image/jpg;base64," + base64Str + "\" alt=\"" + path + "\" title=\"$" + filetype + "$\" id=\"ChatFile\" Width=\"" + bmp.Width.ToString() + "\"/></a>";
webBrowser1.Document.Body.InnerHtml += htm;
}

//Converting image to base64 format
public string ImageToBase64(Image image, System.Drawing.Imaging.ImageFormat format)
{
using (MemoryStream ms = new MemoryStream())
{
// Convert Image to byte[]
image.Save(ms, format);
byte[] imageBytes = ms.ToArray();
// Convert byte[] to Base64 String
string base64String = Convert.ToBase64String(imageBytes);
return base64String;
}
}

Responses
Author: Gowthammanju             
Posted Date: June 14, 2011     Points: 20   

Hey look at the following project url which may help u

http://www.codeproject.com/KB/user-controls/WebBrowserChatUserControl.aspx

Thanks & Regards,
GowthamManju
Chennai



Mark if the answer is true
Author: Gowthammanju             
Posted Date: June 14, 2011     Points: 20   

do not paste the full coding like this just say what are the error you error getting
and whats ur problem that it...

Thanks & Regards,
GowthamManju
Chennai



Mark if the answer is true


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend