"Gerald" <> wrote in
news:#:
> Hi all,
>
> I have a aspx page that inherits from a cs class which is common
> for all pages in my application.
> In that cs file, I define some veriable.
>
> IE:
> the webBasePage.cs:
>
> namespace MyAPP{
> public class myWebBase : System.Web.UI.Page {
> public String myVar = "I'm there";
> }
> }
>
> Then I have the page:
>
> namespace myAPP{
> public class pageTemplate : myWebBase {
> .......
> }
> }
>
> Now I have a user control I add dynamically into the page:
>
> namespace myAPP.controls{
>
> public class clsWebBaseControl : System.Web.UI.UserControl {
> //I would like to be able to access the variable "myVar" I
> declared in
> the first cs file.
> }
> }
>
> How ca I do that.
> I tried : Parent.Page.myVar but it is not recognised.
Gerald,
Try casting Parent.Page:
myWebBase myPage = (myWebBase) Parent.Page;
myPage.myVar = "Hello, world!";
Hope this helps.
Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/