Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Building Controls (http://www.velocityreviews.com/forums/f59-asp-net-building-controls.html)
-   -   Referencing Page properties from child control (http://www.velocityreviews.com/forums/t757870-referencing-page-properties-from-child-control.html)

08-04-2005 02:33 AM

Referencing Page properties from child control
 
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



Matt 08-05-2005 12:41 PM

Re: Referencing Page properties from child control
 
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


08-05-2005 01:38 PM

Re: Referencing Page properties from child control
 
Thanks, Matt. Perfect.

"Matt" <mattmorg55@gmail.com> wrote in message
news:1123245672.364499.34740@g14g2000cwa.googlegro ups.com...
> 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
>




08-05-2005 05:28 PM

Re: Referencing Page properties from child control
 
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
<pheisen@comcast.net> wrote in message
news:efTr%23LcmFHA.4028@TK2MSFTNGP10.phx.gbl...
> Thanks, Matt. Perfect.
>
> "Matt" <mattmorg55@gmail.com> wrote in message
> news:1123245672.364499.34740@g14g2000cwa.googlegro ups.com...
>> 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
>>

>
>




Peter 08-08-2005 11:57 PM

Re: Referencing Page properties from child control
 
OK. Would be glad to use the real class name. How do I know what it is?

Peter
"intrader" <intrader@aol.com> wrote in message
news:pan.2005.08.08.23.00.48.118695@aol.com...
> 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
>> <pheisen@comcast.net> wrote in message
>> news:efTr%23LcmFHA.4028@TK2MSFTNGP10.phx.gbl...
>>> Thanks, Matt. Perfect.
>>>
>>> "Matt" <mattmorg55@gmail.com> wrote in message
>>> news:1123245672.364499.34740@g14g2000cwa.googlegro ups.com...
>>>> 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.
>





All times are GMT. The time now is 05:44 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.