|
|||||||||||||||||||||
|
|||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
Introduction:
UPDATE: Live Sample Using the code
<%@ Page Language="C#" Inherits="LoadingNotifier" Theme="Default" %>
<%
//shahin@themorningoutline.com provided this UNDER GNU GPL
// For more inforamtion visit http://www.themorningoutline.com/
// Page Inhertits the LoadNotifier Class
%>
<!DOCTYPE html >
<html>
<head runat="server">
<title>www.themorningoutline.com ASP.NET Sample</title>
</head>
<body style="background-color: #999999; font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif;">
<% //Initilize thr Progress Bar and show a message
initNotify("Welcome to theMorningOutline. Free tickets from today!");
System.Threading.Thread.Sleep(3000);
%>
<form id="form1" runat="server">
<span style="font-size: 12pt"><strong><span style="color: #ffffff">Select Your Departure
Date: </span></strong> </span>
<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
<br />
<%
// We have achieved a milestone. Let the user know!
Notify("30", "Loading Departure Calendar Completed ...");
// Simulate Internet dalay
System.Threading.Thread.Sleep(2000);
%>
<span style="font-size: 12pt"><span style="color: #ffffff"><strong>Select Your Return
Date: </strong><span style="color: #000000"> </span></span></span>
<asp:Calendar ID="Calendar2" runat="server"></asp:Calendar>
<br />
<%
Notify("60", "Loading Arrival Calendar Completed ...");
System.Threading.Thread.Sleep(2000);
%>
<span style="font-size: 14pt"><span style="color: #ffffff">Your Recent Flights:</span><strong><span
style="color: #ffffff"> </span></strong></span> <br />
<span style="font-size: 12pt"><span style="color: #ffffff"></span>
</span>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
DataSourceID="XmlDataSource" ForeColor="#333333" GridLines="None" Style="border-left-color: gray;
border-bottom-color: gray; border-top-style: outset; border-top-color: gray;
border-right-style: outset; border-left-style: outset; border-right-color: gray;
border-bottom-style: outset">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:BoundField DataField="id" HeaderText="id" SortExpression="id" />
<asp:BoundField DataField="Origin" HeaderText="Origin" SortExpression="Origin" />
<asp:BoundField DataField="Destination" HeaderText="Destination" SortExpression="Destination" />
<asp:BoundField DataField="Duration" HeaderText="Duration" SortExpression="Duration" />
<asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" />
</Columns>
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
<asp:XmlDataSource ID="XmlDataSource" runat="server" DataFile="~/Source.xml" XPath="/travel/Itinerary">
</asp:XmlDataSource>
<%
Notify("100", "Loading Your Previous Trips Completed...");
System.Threading.Thread.Sleep(2000);
%>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
// shahin@themorningoutline.com provided this UNDER GNU GPL
//For more inforamtion visit www.themorningoutline.com
public class LoadingNotifier: System.Web.UI.Page
{
public void initNotify( string StrSplash)
{
// Only do this on the first call to the page
if ((!IsCallback) && (!IsPostBack))
{
//Register loadingNotifier.js for showing the Progress Bar
Response.Write(string.Format(@"<script type='text/javascript' src='scripts/loadingNotifier.js'></script>
<script language="'javascript'" type='text/javascript'>
initLoader('{0}');
</script>",StrSplash));
// Send it to the client
Response.Flush();
}
}
public void Notify(string strPercent, string strMessage)
{
// Only do this on the first call to the page
if ((!IsCallback) && (!IsPostBack))
{
//Update the Progress bar
Remember that the Page_Load event has been processed before the page is being downloaded therefore if you have expensive operations at your Page_Load event, you cannot display the processing progress using this method. This method uses W3C Standard DOM methods which require the body tag to be present to display the progress bar. To display the loading status during Page_Load or other events which are processed prior to sending the page to the client, you can directly write your status message to the Response object and call the Flush method. When the page is completed at the client, you should clean up your status messages.
| ||||||||||||||||||||