Tuesday, January 17, 2012

How to block the ASP.NET page while ajax UpdateProgress is being displayed

Write the css style :

<style type="text/css">
      .hide
      {
          display: none;
      }
      .show
      {
          display: inherit;
      }
       .progressBackgroundFilter
      {
          position: absolute;
          top: 0px;
          bottom: 0px;
          left: 0px;
          right: 0px;
          overflow: hidden;
          padding: 0;
          margin: 0;
          background-color: #000;
          filter: alpha(opacity=50);
          opacity: 0.5;
          z-index: 1000;
      }
      .processMessage
      {
          position: absolute;
          font-family:Verdana;
          font-size:12px;
          font-weight:normal;
          color:#000066;
          top: 30%;
          left: 43%;
          padding: 10px;
          width: 18%;
          z-index: 1001;
          background-color: #fff;
      }
  </style>

Design the Update progress as below :

<asp:UpdateProgress ID="updPrgsBaselineTab" runat="server">
       <ProgressTemplate>
           <div id="progressBackgroundFilter" class="progressBackgroundFilter">
           </div>
           <div id="processMessage" class="processMessage">
               <table width="100%">
                   <tr style="width: 100%">
                       <td style="width: 100%">
                           Please Wait..........
                       </td>
                   </tr>
                   <tr style="width: 100%">
                       <td style="width: 100%" align="center">
                           <img src="../Images/Update_Progress.gif" />
                       </td>
                   </tr>
               </table>
           </div>
       </ProgressTemplate>
   </asp:UpdateProgress>

Hibernate in XP & Code for Hibernate in Windows Application

Below are the steps to enable Hibernate in Windows XP

  1. Right click on Desktop.
  2. Click on properties.
  3. Go to screen save tab.
  4. Click on power button
  5. Select Hibernate tab
  6. Check the checkbox “Enabled Hibernate”
  7. Apply the settings. 

To provide this feature programatically in our .Net windows application



using System.Windows.Forms;

namespace CodeKicks.WinApp.Machine
{
    public static class MyMachineHelper
    {
        public static void DoHibernate()
        {
            //Application.SetSuspendState(PowerState.Suspend, true, false);
            Application.SetSuspendState(PowerState.Hibernate, true, false);
        }
    }
}

Code for adding images to a imagelist from a folder



Public Shared Function InitImageListFromDirectory(pDirectory As String) As ImageList
  Dim imageList As New ImageList()

  For Each f As String In System.IO.Directory.GetFiles(pDirectory)
    Try
      Dim img As Image = Image.FromFile(f)
      imageList.Images.Add(img)
        ' Out of Memory Exceptions are thrown in Image.FromFile if you pass in a non-image file.
    Catch
    End Try
  Next

  Return imageList
 End Function