Home > DeveloperSection > Forums > How to capture screenshot in asp.net
Vani V
Vani V

Total Post:1

Posted on    December-13-2010 9:54 AM

 C# C# 

 1 Reply(s)
 3291  View(s)
Rate this:

Hi All,

 I am trying to take a Screen shot of the client Screen[they are allowed to draw a diagram,when they click save ,it should get saved as Image in database.

Also the user should be able to see it again] . After searching for 2 week ,i implemented the below code in [windows xp,asp.net,C#,SQL]

develpment machine and it works fine. When i deployed the app in Server ,then the problem started.When the Save button is clicked it gave

  System.ComponentModel.Win32Exception: The handle is invalid

[Win32Exception (0x80004005): The handle is invalid]   

System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation) +542 Default3.ThreadMethod() +225

Below is the code

Rectangle bounds = new Rectangle(620, 370, Convert.ToInt32(Panel1.Width.Value) - 20, Convert.ToInt32(Panel1.Height.Value) - 10);   using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))   {     using (Graphics g = Graphics.FromImage(bitmap))     {       g.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size);     }     bitmap.Save(Server.MapPath("~") + "\\ScreenShot\\" + Request.QueryString["TrafficID"].ToString() + ".JPEG", ImageFormat.Jpeg);   } Thanks,

Uttam Misra

Total Post:124

Posted on    December-14-2010 1:00 AM

Hey Why you want to implement it client side? and If you are going to take screenshot then how you going to save in the database? We can implement it easily by using windows service but I am not sure about client side..
and also you will not have any idea about client operating system ...so might be difficult ...
see if you can find something in sliverlight...
Good Luck!!

Don't want to miss updates? Please click the below button!

Follow MindStick