Click here to Skip to main content
15,745,794 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
How To Save Panel As Bitmap Image In Asp.net

Can Anyone Please Tell Me How To save Panel or division as a image on hard drive in
web forms . I M Using VS2008.

Thanx In Advance.
And DrawToBitmap Is A Function used for Window Applications.
Posted
Updated 8-Aug-17 21:04pm
v4
Comments
OriginalGriff 28-Apr-11 3:02am    
Change your user name: Never post your email address in any public forum, unless you really like spam! If anyone replies to you, you will receive an email to let you know
Sandeep Mewara 28-Apr-11 5:09am    
Not clear.
What you mean by:"save Panel or division as a image "?

Is it that you want to take some screenshot and save? Can you be a little elaborate?
kunalsobti89@yahoo.com 29-Apr-11 10:58am    
Like In A webform there is panel or division that contains a textbox and Image Map . I m going to draw a bitmap image And I want that on click of save button this panel or division will save on desktop as a image (jpeg). please help Me if you have any solution.

I'm not quite sure what you want to achieve by this as the ultimate goal, but I can tell you that it is not an easy feat. ASP.NET renders HTML which when received by the browser renders said HTML into a GUI. If I understand you correctly you want part of the HTML which is generated on the server side to be transformed into an image (png, gif, tiff or whatever). In order to do this correctly the rendering engine up to that task would need the whole information that would also be available to the browswer (CSS, javascript, doctype, etc.).
To make a long story short, the complete HTML output of said page would have to be loaded and interpreted by that rendering engine which would add quite some delay to serving your pages. I can't think of any good reason why anybody would put that kind of strain on their web server, but if you can explain what you are really after maybe we can guide you to another solution.

Best regards,

-MRB
 
Share this answer
 
Comments
kunalsobti89@yahoo.com 29-Apr-11 10:59am    
Like In A webform there is panel or division that contains a textbox and Image Map . I m going to draw a bitmap image And I want that on click of save button this panel or division will save on desktop as a image (jpeg). please help Me if you have any solution.
Manfred Rudolf Bihy 29-Apr-11 11:39am    
It's still not clear what you're up to. Please add more details to your question using the "Improve question" link underneath your question.
kunalsobti89@yahoo.com 30-Apr-11 14:15pm    
huh...
This Is The Solution Man-----------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Drawing;
using System.Drawing.Text;
using System.Collections;
using System.ComponentModel;
using System.Reflection;
using System.Data;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;

using System.Web.Security;

using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Text;
using System.Web.SessionState;



System.Drawing.Image image = new Bitmap(800, 100);
System.Drawing.Graphics graphic = Graphics.FromImage(image);

System.Drawing.Drawing2D.LinearGradientBrush lBrush = new LinearGradientBrush(new Rectangle(0, 0, 800, 100), System.Drawing.Color.FromName(ddlbackcolor.Text), System.Drawing.Color.White, 90);
//graphic.DrawRectangle(System.Drawing.Pens.Black, 1, 1, 988, 198);
graphic.FillRectangle(lBrush, 0, 0, 800, 100);
Font font = new Font(DropDownListfontname.SelectedValue, Convert.ToInt32(DropDownListfontsize.SelectedValue), FontStyle.Bold);
//Image img = new System.Web.UI.WebControls.Image(ImageMap1);

graphic.DrawString(txtbannertext.Text, font, Brushes.White, 400, 40);
image.Save(Server.MapPath("/") + "/test.bmp");
 
Share this answer
 
Comments
hajrah 12-Apr-17 2:39am    
Hi, were you able to generate the image for your web panel? i dont see a panel in this code.
I am trying to achieve the exact same thing, to convert a panel in my web form to an image and drawtobitmap is for windows only.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900