Determining control behaviour at design-time/run-time

Discussion in 'ASP .Net' started by Paul Cook, Nov 6, 2003.

  1. Paul Cook

    Paul Cook Guest

    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.
     
    Paul Cook, Nov 6, 2003
    #1
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    875
  2. Tzury Bar Yochay
    Replies:
    3
    Views:
    627
    Jacob Yang [MSFT]
    Nov 29, 2003
  3. =?Utf-8?B?cmtibmFpcg==?=

    Design Time vs Run Time DataGrid

    =?Utf-8?B?cmtibmFpcg==?=, Feb 1, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    695
    Karl Seguin
    Feb 1, 2005
  4. Pierre Yves
    Replies:
    2
    Views:
    751
    Pierre Yves
    Jan 10, 2008
  5. Replies:
    1
    Views:
    597
    Teemu Keiski
    Jul 2, 2003
  6. Zarko Gajic

    Child control renders at desing-time as if it is in run-time...

    Zarko Gajic, Mar 14, 2005, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    248
    Zarko Gajic
    Mar 16, 2005
  7. Replies:
    1
    Views:
    358
    Teemu Keiski
    Dec 8, 2005
  8. Alfonso
    Replies:
    2
    Views:
    164
    Alfonso
    Dec 1, 2006
Loading...