1. Home
  2. Computing & Technology
  3. Delphi Programming

ASP.NET: IsDesignTime

By Zarko Gajic, About.com

If you are doing web control development for ASP.NET, you will often need to know whether your code is executing at design or at run-time. The following function returns true if the code is executing at design time.
Note that the IsDesignTime accepts a System.Web.UI.Page type variable.

~~~~~~~~~~~~~~~~~~~~~~~~~
class function Common.IsDesignTime(Page: System.Web.UI.Page): boolean;
begin
   if NOT Assigned(Page) then
   begin
     Result := True;
     Exit;
   end;

   if Assigned(Page.Site) then
   begin
     Result:= Page.Site.DesignMode;
     Exit;
   end;

   Result := False;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~
Also, note that this is a class function defined in the class named "Common".

An example of usage:

procedure myWebControl.OnInit(e: EventArgs) ;
begin
   inherited;

   if not Common.IsDesignTime(Page) then
     Page.RegisterRequiresPostBack(self) ;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» How to locate and highlight a string in TWebBrowser
« Installing the BDE (manually or using an install program)

Zarko Gajic
Guide since 1998

Zarko Gajic
Delphi Programming Guide

Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2004 Delphi Tips
  7. ASP.NET: IsDesignTime

©2009 About.com, a part of The New York Times Company.

All rights reserved.