Pages

Tuesday 25 June 2013

Taking a Snap Shot of screen in .NET

Introduction: Here I need to take a snap shot my screen with my web application on just a button click.

Requirement: For this I need only a Button, by clicking on that the snap shot of screen is taken and saved                            automatically.

Namespaces Required:

using System.Drawing;

using System.Drawing.Imaging;

Click event of Button:

        Bitmap bitmap = new Bitmap(1000, 1000); //declaring size of snap
        Graphics graphics = Graphics.FromImage(bitmap as System.Drawing.Image);
        graphics.CopyFromScreen(0, 0, 0, 0, bitmap.Size);
        bitmap.Save(@"c:\Snapshot\screenshot1.bmp", ImageFormat.Bmp); //Path to save image

Result:  
        This code will save the snap shot of screen to the location defined in the code.

Friday 7 June 2013

Fade background screen while loading

CSS:-

<style>
   .overlay 
{
position: fixed;
background-image:url('../images/loadingnew.gif');
background-repeat:no-repeat;
background-position:center;
background-color:Black;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
opacity: 0.2;
-moz-opacity: 0.2;
filter: alpha(opacity=20);
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=20)";
z-index: 10000;
}
</style>


Now at your design page just use a Update Progress like this- 

  <asp:UpdateProgress ID="UpdateProgress2" runat="server" DynamicLayout="true">
          <ProgressTemplate>
               <div class="overlay"></div>
          </ProgressTemplate>
        </asp:UpdateProgress>

Don't forget to declare ScriptManager in your design page, and place your controls in UpdatePanel.
On the click event of button use this code-

        System.Threading.Thread.Sleep(2000);




Saturday 1 June 2013

Refreshing Parent page from child page using JavaScript

use this javascript function on ypur child page :
 <script type="text/javascript">
    function closechildwindow() {
        window.opener.document.location.href = '(parent page url)';
        window.close();
    }
</script>

now in the body tag of your child page call the function like this:
<body onunload="closechildwindow()">