sanjuro
sanjuro

Reputation: 1661

What is Control's DesignMode property and how to use it?

what is DesignMode property? When it is useful? I don't understand it from msdn definition http://msdn.microsoft.com/en-us/library/system.web.ui.control.designmode.aspx

Some example? Thanks for answer.

Upvotes: 3

Views: 2402

Answers (3)

dkackman
dkackman

Reputation: 15579

One example of when you might use DesignMode is for design time specific behavior, for instance is when creating a custom control and you want to set its display text equal to the name of the control:

if (DesignMode && string.IsNullOrEmpty(Text))
  Text = Name;

Upvotes: 1

Ikaso
Ikaso

Reputation: 2268

This is a property that let's you know if you are running in Visual Studio Designer. It is helpful when you are writing a custom control and you want it to behave differently during design time.

Upvotes: 1

ZippyV
ZippyV

Reputation: 13048

The DesignMode property will be set to True when you are editing your asp.net page in Visual Studio. For example if you create a chart control you could show a chart based on dummy data during design-time and at run-time generate a chart based on the provided data.

Upvotes: 7

Related Questions