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()">

Monday 20 May 2013

Using CURSOR in SQL


DECLARE @variable int  -- Declaring variable to use in cursor 
-- You can declare as many variables as per your need
--------------------------------------------------------
DECLARE @cursorName CURSOR   -- Declaring cursor
SET @cursorName = CURSOR FAST_FORWARD
FOR
SELECT column_name FROM   Table_Name   -- query for cursor
OPEN @cursorName
FETCH NEXT FROM @cursorName
INTO @variable
WHILE @@FETCH_STATUS = 0
BEGIN
update Table_Name set column_name= something where column_name=something -- write your query here

FETCH NEXT FROM @cursorName
INTO @variable
END
CLOSE @cursorName
DEALLOCATE @cursorName

Sunday 12 May 2013

Slide out Tab using javascript

Code For <head></head> Secction :-

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script>
<script src="http://tab-slide-out.googlecode.com/files/jquery.tabSlideOut.v1.3.js" type="text/javascript"></script>

<script type="text/javascript">
    $(function () {
        $('.slide-out-div').tabSlideOut({
            tabHandle: '.handle',                     //class of the element that will become your tab
            pathToTabImage: 'http://wpaoli.building58.com/wp-content/uploads/2009/09/contact_tab.gif', //path to the image for the tab //Optionally can be set using css
            imageHeight: '122px',                     //height of tab image           //Optionally can be set using css
            imageWidth: '40px',                       //width of tab image            //Optionally can be set using css
            tabLocation: 'right',                      //side of screen where tab lives, top, right, bottom, or left
            speed: 400,                               //speed of animation
            action: 'click',                          //options: 'click' or 'hover', action to trigger animation
            topPos: '200px',                          //position from the top/ use if tabLocation is left or right
            leftPos: '20px',                          //position from left/ use if tabLocation is bottom or top
            fixedPosition: true,                      //options: true makes it stick(fixed position) on scroll
            onSlideOut: function () {
                alert('Opened');
            },
            onSlideIn: function () {
                alert('Closed');
            }
        });

    });
</script>

<style type="text/css">
.slide-out-div {
  padding: 20px;
  width: 250px;
  background: #ccc;
  border: 1px solid #29216d;
 }    
 </style>


Code for <body></body> Section: -

<div class="slide-out-div">
    <a class="handle" href="http://link-for-non-js-users.html">Content</a>
     <h1> Feedback form</h1>
    <table class="container">
     
        <tr>
            <td class="style1">
                <asp:Label ID="Label6" runat="server" Text="Mail ID"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="TextBox6" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style1">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style1">
                <asp:Label ID="Label7" runat="server" Text="Feedback"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="TextBox7" runat="server" TextMode="MultiLine" Height="50px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style1">
                &nbsp;</td>
            <td>
                <asp:Button ID="Button1" runat="server" Text="Button" />
            </td>
        </tr>
    </table>
 </div>