Referencing Page properties from child control

Discussion in 'ASP .Net Building Controls' started by Guest, Aug 4, 2005.

  1. Guest

    Guest Guest

    I'm declaring public properties in a Page's code behind file (not
    declaratively). I would like to read and assign these from a child
    control's cs file. The Page's inherits attribute is _Default. So, for
    example, I would like to reach _Default.StudentID where StudentID is a
    public property of _Default. Seems this should be doable but cannot figure
    it out.

    Thanks,

    Peter
    Guest, Aug 4, 2005
    #1
    1. Advertising

  2. Guest

    Matt Guest

    You need to cast the Page reference to the type of the code-behind
    class ... So in the code-behind for the User Control do something like:

    ((_Default)this.Page).StudentID
    Matt, Aug 5, 2005
    #2
    1. Advertising

  3. Guest

    Guest Guest

    Thanks, Matt. Perfect.

    "Matt" <> wrote in message
    news:...
    > You need to cast the Page reference to the type of the code-behind
    > class ... So in the code-behind for the User Control do something like:
    >
    > ((_Default)this.Page).StudentID
    >
    Guest, Aug 5, 2005
    #3
  4. Guest

    Guest Guest

    Matt, Looked great but here's a line in my user control:

    int status = ((_Default)this.Page).Status;

    Doesn't compile. Asks "Are you missing Using statement or Assembly...?"

    Suggestions?

    Peter
    <> wrote in message
    news:efTr%...
    > Thanks, Matt. Perfect.
    >
    > "Matt" <> wrote in message
    > news:...
    >> You need to cast the Page reference to the type of the code-behind
    >> class ... So in the code-behind for the User Control do something like:
    >>
    >> ((_Default)this.Page).StudentID
    >>

    >
    >
    Guest, Aug 5, 2005
    #4
  5. Guest

    Peter Guest

    OK. Would be glad to use the real class name. How do I know what it is?

    Peter
    "intrader" <> wrote in message
    news:p...
    > On Fri, 05 Aug 2005 13:28:39 -0400, pheisen wrote:
    >
    >> Matt, Looked great but here's a line in my user control:
    >>
    >> int status = ((_Default)this.Page).Status;
    >>
    >> Doesn't compile. Asks "Are you missing Using statement or Assembly...?"
    >>
    >> Suggestions?
    >>
    >> Peter
    >> <> wrote in message
    >> news:efTr%...
    >>> Thanks, Matt. Perfect.
    >>>
    >>> "Matt" <> wrote in message
    >>> news:...
    >>>> You need to cast the Page reference to the type of the code-behind
    >>>> class ... So in the code-behind for the User Control do something like:
    >>>>
    >>>> ((_Default)this.Page).StudentID
    >>>>
    >>>
    >>>

    > Use the real class name. _Default is just syntactic sugar.
    >
    Peter, Aug 9, 2005
    #5
    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. Jeff Rodriguez
    Replies:
    23
    Views:
    1,092
    David Schwartz
    Dec 9, 2003
  2. Steve Hershoff

    Referencing a parent control from a child?

    Steve Hershoff, Jul 30, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    401
    Steve Hershoff
    Jul 31, 2006
  3. Steve Hershoff

    Referencing a parent control from a child?

    Steve Hershoff, Jul 30, 2006, in forum: ASP .Net Building Controls
    Replies:
    4
    Views:
    133
    Steve Hershoff
    Jul 31, 2006
  4. Donal McWeeney

    Mixing child properties and child controls - how?

    Donal McWeeney, Feb 10, 2005, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    118
    [MSFT]
    Feb 14, 2005
  5. Steve Hershoff

    Referencing a parent control from a child?

    Steve Hershoff, Jul 30, 2006, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    161
    Steve Hershoff
    Jul 31, 2006
Loading...

Share This Page