Click here to Skip to main content
12,954,522 members (62,044 online)
Click here to Skip to main content
Add your own
alternative version


22 bookmarked
Posted 26 Dec 2007

How to display animation on long operations without partial post back

, 31 Jan 2008 CPOL
Rate this:
Please Sign up or sign in to vote.
Will show how to render a 'please wait page' for display while server is processing a lengthy operation.


This article will show how to render a 'please wait page' while the web server is performing a lengthy operation.


Animated GIFs are a good way to show users that an application is busy. If you have ever tried to display an animated GIF using client side scripting on a user initiated postback, you will know that the GIF is frozen at the first frame. This happens because IE shuts down the background thread while posting back.

The AJAX partial postback feature resolves the frozen animation issue, but does not work well if the page contains certain controls such as validators.

Using the code

The source code consists of a single class that I have named LongOperation. This class is statically initialized with the URL of a 'long operation page' that will be rendered to the web client while processing the lengthy operation. Three lines of code are needed to animate your lengthy operations as shown in the btnDoOperation_Click event handler below.

namespace ByteTec.OnSubmitAnimation.Demo {
    /// <summary>
    /// Will simulate a long running operation by sleeping for a period of time.
    /// </summary>
    public partial class LongOperationStart : System.Web.UI.Page {
        /// <summary>
        /// Initializes the <see cref="LongOperationStart"/> class.
        /// </summary>
        static LongOperationStart() {
            ByteTec.Web.LongOperation.LongOperationPageUrl = 
               ApplicationUrl + "/LongOperationAnimation.aspx";
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load"></see> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"></see>
        /// object that contains the event data.</param>
        protected override void OnLoad(EventArgs e) {
            btnDoOperation.Click += new EventHandler(btnDoOperation_Click);
        /// <summary>
        /// Handles the Click event of the btnDoOperation control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/>
        /// instance containing the event data.</param>
        void btnDoOperation_Click(object sender, EventArgs e) {
            ByteTec.Web.LongOperation _longOperation = 
                    new ByteTec.Web.LongOperation(this);
        /// <summary>
        /// Gets the application URL.
        /// </summary>
        /// <value>The application URL.</value>
        private static string ApplicationUrl {
            get {
                if (HttpContext.Current.Request.Url.IsDefaultPort) {
                    return HttpContext.Current.Request.Url.Scheme + "://" + 
                } else {
                    return HttpContext.Current.Request.Url.Scheme + "://" + 
                      HttpContext.Current.Request.Url.Host + ":" + 


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Tore Olav Kristiansen
Technical Lead Collabora AS
Norway Norway
My name is Tore Olav Kristiansen and I am a developer. I am passionate about making coherent people-friendly solutions.

I have worked as a software engineer for 16 years, the last 10 mostly on the SharePoint platform. I am the founder of Collabora and Collabora Apps.

I have a masters in computer science from the University of Stavanger, Norway.

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170525.1 | Last Updated 31 Jan 2008
Article Copyright 2007 by Tore Olav Kristiansen
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid