ASP.NET - How To Display Animated .GIF On Postback

When designing an interactive web page, it is important for you to let the user know that  an action initiated by him/her is in progress.One way to do this is to display an animated .GIF on postback and hide it after the page trip to the server. It would also serve well to disable further inputs from the user until the postback is completed. 

Below is a simple  ASP.NET page with javascript to display an animated .GIF and disable the button till theirs a response from the server .


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="About.aspx.cs" Inherits="About" %>

<!DOCTYPE html>
<html lang="en" >

<head>
  <title>Login Form</title>  
    <script language="javascript" type="text/javascript">

        window.onbeforeunload = function () {
            //Disable the button
            document.getElementById('<%=btnContinue.ClientID %>').disabled = true;
            //show the animated image.
            document.getElementById('<%=imgLoader.ClientID%>').style.visibility = 'visible';
        }
    </script>
</head>

<body >      
    <form id="Form1" method="post" runat="server">         
    <table style="width: 100%;">
        <tr>
            <td class="style6">
                &nbsp;
                <asp:Label ID="Label1" runat="server" Text="Username :"></asp:Label>
            </td>
            <td class="style7">
                &nbsp;
           
          <asp:TextBox ID="txtUsername" placeholder="Username" runat="server"></asp:TextBox>
            </td>
            <td class="style8">
                &nbsp;
              
            </td>
        </tr>
        <tr>
            <td class="style6">
                &nbsp;
                <asp:Label ID="Label2" runat="server" Text="Password :"></asp:Label>
            </td>
            <td class="style7">
                &nbsp;
           
          <asp:TextBox ID="txtPassword" placeholder="Password" runat="server" TextMode="Password"></asp:TextBox>
            </td>
            <td class="style8">
                &nbsp;
               
            </td>
        </tr>
        <tr>
            <td class="style1">
                &nbsp;
            </td>
            <td class="style2">
                &nbsp;
           
        <asp:Button ID="btnContinue" runat="server" Text="Continue"
                     onclick="btnContinue_Click"
                    Width="287px"  />
            </td>
            <td class="style9">
                &nbsp;
            </td>
        </tr>
    </table>
       <p>
       <asp:Image ID="imgLoader" runat="server" Height="52px"
                            ImageUrl="~/img/ajax-loader.gif" style="visibility:hidden" Width="62px" />
       </p>
    </form>
</body>

</html>




Page before postback

Page during post back. *Note that the button was disabled during postback




SQL - How To Backup All Databases In MS SQL Server Instance

SQL - How To Backup All Databases In MS SQL Server Instance
If you would like to backup all the databases in an instance of  MS SQL server , you can run the following script in the query window of that instance  . Remember to change the path 'C:\Backup\' to the path on your own system .

 DECLARE @name VARCHAR(50) -- database name 
DECLARE @path VARCHAR(256) -- path for backup files 
DECLARE @fileName VARCHAR(256) -- filename for backup 
DECLARE @fileDate VARCHAR(20) -- used for file name

-- specify database backup directory
SET @path = 'C:\Backup\' 

-- specify filename format
SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112)

DECLARE db_cursor CURSOR READ_ONLY FOR 
SELECT name
FROM master.dbo.sysdatabases
WHERE name NOT IN ('master','model','msdb','tempdb')  -- exclude these databases

OPEN db_cursor  
FETCH NEXT FROM db_cursor INTO @name  

WHILE @@FETCH_STATUS = 0  
BEGIN  
   SET @fileName = @path + @name + '_' + @fileDate + '.BAK' 
   BACKUP DATABASE @name TO DISK = @fileName 

   FETCH NEXT FROM db_cursor INTO @name  
END  


CLOSE db_cursor  
DEALLOCATE db_cursor

ASP.NET - How To Display Animated .GIF On Postback

When designing an interactive web page, it is important for you to let the user know that  an action initiated by him/her is in progress.One...