ASP.Net Server Control's Site is ALWAYS Nothing

Discussion in 'ASP .Net Building Controls' started by Jason Butera, Jun 14, 2004.

  1. Jason Butera

    Jason Butera Guest

    I want to set the datasource to a server control at run-time only
    (because the datasource is stored in the web cache). The following
    code I thought should do the trick, but Site is ALWAYS nothing.

    If Not Me.Site Is Nothing AndAlso Me.Site.DesignMode = False Then
    'My Code for run-time only
    End If

    I tried it in the constructor and onload events. Why is site always
    nothing?
    Jason Butera, Jun 14, 2004
    #1
    1. Advertising

  2. "Jason Butera" <> wrote in message
    news:...
    > I want to set the datasource to a server control at run-time only
    > (because the datasource is stored in the web cache). The following
    > code I thought should do the trick, but Site is ALWAYS nothing.
    >
    > If Not Me.Site Is Nothing AndAlso Me.Site.DesignMode = False Then
    > 'My Code for run-time only
    > End If
    >
    > I tried it in the constructor and onload events. Why is site always
    > nothing?


    Because Site is a design-time concept. There is no site at runtime. You
    want:

    If Me.Site Is Nothing OrElse Me.Site.DesignMode = False Then
    ' Code for run-time only
    End If

    --
    John Saunders
    johnwsaundersiii at hotmail
    John Saunders, Jun 15, 2004
    #2
    1. Advertising

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. Ma³y Piotruœ

    ASP.NET: HtmlInputHidden = Nothing

    Ma³y Piotruœ, Dec 4, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    614
    Ma³y Piotruœ
    Dec 4, 2005
  2. Deryck
    Replies:
    4
    Views:
    506
    derek giroulle
    Jun 22, 2004
  3. mark4asp
    Replies:
    1
    Views:
    1,121
    Steve C. Orr [MCSD, MVP, CSM, ASP Insider]
    Mar 24, 2007
  4. happykid
    Replies:
    6
    Views:
    628
    WaffleSouffle
    Aug 9, 2011
  5. Devin Jeanpierre
    Replies:
    2
    Views:
    427
    Devin Jeanpierre
    Feb 14, 2012
Loading...

Share This Page