Wednesday, February 18, 2009

Ajax "Processing" modal window with CSS

Ajax which means Asynchronous JavaScript And XML is a technology in which you can refresh the web page without having the flickering effect. Thus it gives a rich user experience. Now, when implementing Ajax in our web application we always thing of using some dazzy logo/animation which will indicate the user that some processing is happening in the background. At the same time we want to prevent the user from clicking other links/buttons on the web page. Here is some thing that we want to achieve:

Ajax Processing Panel

We generally have multiple web pages in our web application. In each of those pages we use the UpdatePanel control of to enable Ajax processing. The display of such a processing panel can be achieved using the UpdateProgress control of The aspx code will look as shown below:
<asp:UpdatePanel ID="updateGrid" runat="server" ChildrenAsTriggers="true"
<asp:UpdateProgress ID="UpdateProgress1" AssociatedUpdatePanelID="updateGrid"
runat="server" DynamicLayout="true" DisplayAfter="0">
<asp:Panel ID="pnlAjaxProcessing" CssClass="ajaxProcessingContainerDiv"
<table class="ajaxProcesingTable">
<td class="ajaxProcesingImageTD">
<br />
<asp:Image ID="imgProgressBar" ImageUrl="~/Images/ajaximage.gif"
runat="server" />
<br />
<td class="ajaxProcesingTextTD">
<br />


The CSS Class are given below:
border: 0;
height: 10%;
width: 20%;
position: fixed;
_position: absolute;
left: 40%;
top: 40%;
color: black;
z-index: 100;


width :100%;
height: 100%;
border: 1px solid LightBlue;
background-color : White;

text-align :center ;

text-align :center;
color: #0067a2;
font-size :medium;
Here we can have one improvement. Instead of using the Ajax Processing Panel (pnlAjaxProcessing) in every page, we can create a user control for it and use that user control in all the pages. The advantage is, if in future we want to change the ajax processing image or the text displayed, then we will have to make changes in the user control and it will get reflected in all other pages.

Hope this helps!


Post a Comment