Determining control behaviour at design-time/run-time

P

Paul Cook

Hi

I am trying to determine whether a control is being displayed at
designtime or runtime but this piece of code doesn't seem to work
correctly. Note that this is not a web user control (ascx) although
this control does end up being used on an ascx control.

The expression always evaluates false (the else part - runtime!)

public class AccountDropDownList :
System.Web.UI.WebControls.DropDownList
{
public AccountDropDownList()
{
if(Site != null && Site.DesignMode)
{
this.Items.Add(new ListItem("Design time"));
}
else
{
this.Items.Add(new ListItem("Run time"));
}
}
}

Any help would be greatly appreciated, Paul.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top