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:
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:
How can I make the MyPage class available within MyControl without adding a Reference directive to MyPage from MyControl?
Thanks
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