-[Danny Chen]- Blog of an ASP.NET QA tester

Tips and info about Site Navigation, ImageMap, Menu and other cool ASP.NET v2.0 features.

Custom Control Challenge - Entry #2

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Threading;

namespace PageLoadingDisplayControls {
    [
ToolboxData("<{0}:PageLoadingDisplay runat=server></{0}:PageLoadingDisplayControl>")]
    [
Designer(typeof(PageLoadingDisplayDesigner))]
    
public class PageLoadingDisplay : WebControl {
        
protected override void OnInit(EventArgs e) {
            Page.Response.Buffer =
true;
            
base.OnInit(e);

            Page.Response.Write(
@"
            <![CDATA[
            Pad the buffer otherwise IE does not render on flush
            Padding not required for Firefox
            ]]>
            <div id=""imgLoading"">
            <img src=""images/loading.gif"" alt=""Loading"" />
            </div>"
);

            Page.Response.Flush();
            Page.ClientScript.RegisterStartupScript(
this.GetType(),
              
"foo",
              
"document.getElementById('imgLoading').style.display='none';",
              
true);
        }

    }
}

Control Designer:

using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Web.UI;
using System.Web.UI.Design;
using System.Web.UI.Design.WebControls;
using System.Web.UI.WebControls;
using System.Reflection;

namespace PageLoadingDisplayControls {
    
public class PageLoadingDisplayDesigner : ControlDesigner {
        
public override string GetDesignTimeHtml() {
            
Control control = base.ViewControl;
            
return "[PageLoadingDisplay : " + control.ID + "]";

        }
    }
}
 
 
 

 
Posted: Mar 02 2006, 09:40 AM by dannychen | with 7 comment(s)
Filed under:

Comments

Khurram shahzad said:

I have tried to add this code on page init functions but i am not seeing same behaviour. what could be the reason. i simply copy pasted the oninit code in page oninit funciton to see if i can get same result on page..

Please elaborate. .Thanks..

# October 8, 2007 9:28 PM

Waverly said:

Good morning. Early morning cheerfulness can be extremely obnoxious. Help me! I find sites on the topic: Baby girl bedding sets. I found only this - <a href="baby-bedding.net/">organic baby bedding</a>. Max delius opens mulisch, bedding. This sorely rumored to the rejection finding its fuzzy cycle, liquor, bedding. :confused: Thanks in advance. Waverly from Greece.

# March 24, 2010 2:50 PM

Lara Dutta said:

Hush Hush papa sleepping...

# April 28, 2010 2:08 AM

Janine said:

At last, somonee comes up with the "right" answer!

# January 18, 2012 5:51 AM

Kaylie said:

These topics are so cnofusnig but this helped me get the job done.

# January 19, 2012 10:37 PM

lurcehnvpzq said:

xsnSLq  <a href="nvoummndtrpf.com/.../a>

# January 20, 2012 5:20 AM

qteugx said:

acJ0ca  <a href="pcbcclbfztwy.com/.../a>

# January 22, 2012 2:33 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)