Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Referencing Page properties from child control

Reply
Thread Tools

Referencing Page properties from child control

 
 
Guest
Posts: n/a
 
      08-04-2005
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


 
Reply With Quote
 
 
 
 
Matt
Guest
Posts: n/a
 
      08-05-2005
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

 
Reply With Quote
 
 
 
 
Guest
Posts: n/a
 
      08-05-2005
Thanks, Matt. Perfect.

"Matt" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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
>



 
Reply With Quote
 
Guest
Posts: n/a
 
      08-05-2005
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
<(E-Mail Removed)> wrote in message
news:efTr%(E-Mail Removed)...
> Thanks, Matt. Perfect.
>
> "Matt" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) 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
>>

>
>



 
Reply With Quote
 
Peter
Guest
Posts: n/a
 
      08-08-2005
OK. Would be glad to use the real class name. How do I know what it is?

Peter
"intrader" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> 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
>> <(E-Mail Removed)> wrote in message
>> news:efTr%(E-Mail Removed)...
>>> Thanks, Matt. Perfect.
>>>
>>> "Matt" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed) 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.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Referencing a parent control from a child? Steve Hershoff ASP .Net Web Controls 4 07-31-2006 05:25 PM
Referencing a parent control from a child? Steve Hershoff ASP .Net 4 07-31-2006 05:25 PM
Referencing a parent control from a child? Steve Hershoff ASP .Net Building Controls 4 07-31-2006 05:25 PM
Mixing child properties and child controls - how? Donal McWeeney ASP .Net Web Controls 3 02-14-2005 02:51 AM
How do I: Main thread spawn child threads, which child processes...control those child processes? Jeff Rodriguez C Programming 23 12-09-2003 11:06 PM



Advertisments