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

ASP.NET: IsDesignTime

By , About.com Guide

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)

Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. 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.