Ask a Question related to ASP.NET General, Design and Development.
-
Gerald #1
accessing page variable from user control code behind
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.
Could someone help me?
Thanks
Gerald
Gerald Guest
-
User control not seen on code beside (behind) page
Can someone shed some light on how to get this user control to work? I created a simple user control with several properties (I want to access... -
user control problem access value from user control to a page
Thanks a lot for paying attention to my problem , i tell u the problem i have a main form in which i gave a login label that points to a... -
Accessing User Control inside Datagrid
I've created a simple user control (dynamically populated dropdown list via database) and dynamically added it to a datagrid. There are 9 instances... -
User Control - Accessing Properties from the Container Page
Dear all, Please check my problem - Problem: I have created a User Control(UC1) for navigating between pages. There are 4 buttons on the user... -
Accessing Web User Control from code behind
How come I am unable to access the properties and methods of my Web User Control from the codebehind of an aspx page Any ideas how how to do this... -
Chris R. Timmons #2
Re: accessing page variable from user control code behind
"Gerald" <gege107@hotmail.com> wrote in
news:#AzbZaiQDHA.704@tk2msftngp13.phx.gbl:
Gerald,> 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.
Try casting Parent.Page:
myWebBase myPage = (myWebBase) Parent.Page;
myPage.myVar = "Hello, world!";
Hope this helps.
Chris.
-------------
C.R. Timmons Consulting, Inc.
[url]http://www.crtimmonsinc.com/[/url]
Chris R. Timmons Guest



Reply With Quote

