Note that there are some explanatory texts on larger screens.

plurals
  1. POaspx does not contain a definition for this.Bounds
    primarykey
    data
    text
    <p>hello everyone i am writing a program which captures a part of the screen when a button is clicked. Below is my code</p> <pre><code>**default.aspx** &lt;%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="_9marchexp._Default" %&gt; &lt;asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"&gt; &lt;/asp:Content&gt; &lt;asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"&gt; &lt;h2&gt; Welcome to ASP.NET! &lt;/h2&gt; &lt;p&gt; To learn more about ASP.NET visit &lt;a href="http://www.asp.net" title="ASP.NET Website"&gt;www.asp.net&lt;/a&gt;. &lt;/p&gt; &lt;p&gt; You can also find &lt;a href="http://go.microsoft.com/fwlink/?LinkID=152368&amp;amp;clcid=0x409" title="MSDN ASP.NET Docs"&gt;documentation on ASP.NET at MSDN&lt;/a&gt;. &lt;/p&gt; &lt;p&gt; &amp;nbsp;&lt;/p&gt; &lt;p&gt; &amp;nbsp;&lt;/p&gt; &lt;p&gt; &lt;asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" /&gt; &lt;/p&gt; &lt;/asp:Content&gt; </code></pre> <p>and </p> <p><strong>default.aspx.cs</strong></p> <pre><code>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.Data; using System.Runtime.InteropServices; using System.ComponentModel; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; using System.Drawing.Imaging; namespace _9marchexp { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { Rectangle formRect = this.Bounds; // saving information aout your window in formRect &lt;br/&gt; // (height, width, x, y, etc using (Bitmap bitm = new Bitmap(formRect.Width, formRect.Height)) // creating new bitmap of the same &lt;br/&gt; // height and width as our own window { using (Graphics graphic = Graphics.FromImage(bitm)) { graphic.CopyFromScreen(new Point(formRect.Left, formRect.Top), Point.Empty, formRect.Size); } bitm.Save("C:\\Users\\xxxx\\Desktop\\myscreenshot.jpg", ImageFormat.Jpeg); // saving the bitmap bile to destination dir. &lt;br/&gt; // with specified name } } } } </code></pre> <p>however the thing is when i execute the code an error message is displayed </p> <pre><code>***'_9marchexp._Default' does not contain a definition for 'Bounds' and no extension method 'Bounds' accepting a first argument of type '_9marchexp._Default' could be found (are you missing a using directive or an assembly reference?)*** </code></pre> <p>How to correct that, can someone help me??</p> <p>also if i replace <strong>this.Bounds</strong> with <strong>Screen.PrimaryScreen.Bounds</strong> the code runs perfectly but the screenshot of the whole screen is taken which i don't want. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload