Ask a Question related to ASP.NET General, Design and Development.
-
William F. Robertson, Jr. #1
Re: Referencing Custom Page Class within a Control
C# code.
MyPageClass myPage = ( MyPageClass ) this.Page;
myPage now is the instance of MyPageClass the control on.
bill
"Cheung, Jeffrey Jing-Yen" <jingyen@emailREMOVEMEuser.net> wrote in message
news:#4TSSmwRDHA.384@TK2MSFTNGP12.phx.gbl...> How do I obtain a reference to a Custom Page object written that
> inherits System.Web.UI.Page when the control exists on that custom page?
> Referencing Me.Page doesn't work as it goes directly to the base class
> System.Web.UI.Page.
>
> Ex: (please mind the word wrap)
>
> This is my custom page class:
>
> Public Class MyPageClass
> Inherits CWebPage
> ' My protected instance variable that I want to access from the control
> Protected m_myvar As Boolean
> '... irrelevant overloaded methods here
> '...
> End Class
>
>
> On the presentation layer, I have a control that is correctly registered
> via the Register directive
>
> <%@ Register TagPrefix="userControl" TagName="MyControl"
> Src="..path/to/my/control.ascx" %>
>
> In my control codebehind, I need to obtain a reference to the Custom
> Page class ->
>
>
> Public Class MyControl
> Inherits WebControl
> Public Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> ' I need to obtain a reference to the custom page object to get my
> protected instance variable value.
> End Sub
> End Class
>
>
> Thanks in advance,
>
> Jeff Cheung
>
William F. Robertson, Jr. Guest
-
Custom Control Class within a class
I think that this problem might relate to another that I posted. I did a page trace of my custom control and see that OnInit is called every time... -
Referencing Page properties from child control
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... -
Custom control code serialization to class file
I have a custom control that includes a custom collection. In the collection editor, I add a new item to the collection and that item gets... -
Using a component class as a property for a custom control
Hi, I'm working on a .net application where i'd like to implement the same design-time behavior as used when working with... -
Page Load fired 3 times Web user control is embedded in a custom control
Hi, I have built a custom control that build a table with 3 cells in it. The custom control is designed to add all child controls to cell#2,... -
Cheung, Jeffrey Jing-Yen #2
Re: Referencing Custom Page Class within a Control
William,
Thanks so much!
For reference, here's the VB.NET equivalent:
' Begin Code Snippet
Dim MyPageClass As MyPageClass
MyPageClass = Me.Page
' End Code Snippet
Jeff Cheung
William F. Robertson, Jr. wrote:
> C# code.
>
>
> MyPageClass myPage = ( MyPageClass ) this.Page;
>
> myPage now is the instance of MyPageClass the control on.
>
> bill
>
>
>
> "Cheung, Jeffrey Jing-Yen" <jingyen@emailREMOVEMEuser.net> wrote in message
> news:#4TSSmwRDHA.384@TK2MSFTNGP12.phx.gbl...
>>>>How do I obtain a reference to a Custom Page object written that
>>inherits System.Web.UI.Page when the control exists on that custom page?
>> Referencing Me.Page doesn't work as it goes directly to the base class
>>System.Web.UI.Page.
>>
>>Ex: (please mind the word wrap)
>>
>>This is my custom page class:
>>
>>Public Class MyPageClass
>>Inherits CWebPage
>>' My protected instance variable that I want to access from the control
>>Protected m_myvar As Boolean
>>'... irrelevant overloaded methods here
>>'...
>>End Class
>>
>>
>>On the presentation layer, I have a control that is correctly registered
>>via the Register directive
>>
>><%@ Register TagPrefix="userControl" TagName="MyControl"
>>Src="..path/to/my/control.ascx" %>
>>
>>In my control codebehind, I need to obtain a reference to the Custom
>>Page class ->
>>
>>
>>Public Class MyControl
>>Inherits WebControl
>>Public Sub Page_Load(ByVal sender As System.Object, ByVal e As
>>System.EventArgs) Handles MyBase.Load
>>' I need to obtain a reference to the custom page object to get my
>>protected instance variable value.
>>End Sub
>>End Class
>>
>>
>>Thanks in advance,
>>
>>Jeff Cheung
>>
>
>Cheung, Jeffrey Jing-Yen Guest



Reply With Quote

