Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I cast this.Page to the aspx file loading the user control.

Status
Not open for further replies.

mbutch

Programmer
Nov 17, 2000
100
US
I'm Using Visual Studio 2005 Beta with the .Net Framework 2.0 Beta.

I want to access a public property on an aspx page (MyPage) from a user control (MyControl) loaded on that page. I can access the Page property on my user control like so:
Code:
this.Page;

This returns the Page object, but I'm unable to cast it to a MyPage object. The MyPage_aspx class is not available to me. If I add a reference directive on MyControl to MyPage I get a "Circular file references are not allowed." error, which I understand, because if I actually loaded MyPage it would cause an infinite loop. However, a Reference or Register directive is the only way I know of to make a Web Form or User Control class available from the code behind page.

This is basically what I want to do on my user control:
Code:
MyPage tempPage = (MyPage)this.Page;
tempPage.MyProperty = 1;

How can I make the MyPage class available within MyControl without adding a Reference directive to MyPage from MyControl?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top