Code below is not working as expected to detect if it is in design mode (VS.Net 2003 – Control Library):
if (this.Site != null && this.Site.DesignMode == true)
{
// Design Mode
}
else
{
// Run-time
}
It is used in a complex user control, deriving from another user control and including other user controls on it.
Is there another way to detect design time in a VS.NET 2003 or what is the problem with the code above?
DesignModewon’t work from inside a constructor. Some alternatives (not sure if they work in 1.1) areif (System.ComponentModel.LicenseManager.UsageMode == System.ComponentModel.LicenseUsageMode.Designtime)or
call
GetService(typeof(IDesignerHost))and see if it returns something.I’ve had better luck with the first option.