• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1094
  • Last Modified:

UserControl -- detecting designtime vs runtime

I have a UserControl I am developing.

How can I have it detect when it is in designtime vs runtime?  I want certain behavior at designtime.
0
Tom Knowlton
Asked:
Tom Knowlton
  • 4
  • 2
1 Solution
 
AlexFMCommented:
if ( Site.DesignMode )
{
    // control is in design mode
}
0
 
AlexFMCommented:
To be presize, we should talk about control's site (container) design mode, and not about control design mode. When control itself is in design mode, it's code is not running. However, control's site can be in design or runtime mode, in both cases control's code is executed, and control itself is in runtime mode.
0
 
Tom KnowltonWeb developerAuthor Commented:
What is the difference between:

if ( Site.DesignMode )
{
    // control is in design mode
}

and

if ( this.DesignMode )
{
    // control is in design mode
}


???
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Tom KnowltonWeb developerAuthor Commented:
Let me ask you this.....for a User Control....I know that you can have Properties that you set at Design Time and they will affect the controls at design time.

For example....the Font property when clicked on shows a small little box with three dots   .  .  .    which when you click on the box it brings up a Font Dialog.

Is it possible to have a property that has the same thing....except when you click on the dots box  it  opens a CUSTOM Dialog box that I have created myself?   And then how would I tie that dialog box to the User Control ?
0
 
AlexFMCommented:
I think this.DesignMode called from control itself will always returns false when contrrol code is executed. When control is in design mode, it's code is not running, and there is no chance to get true.
When control is part of the form (container, site), control's site design mode may be true or false.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now