Accessing _Default page from a child derived from UserControl (Express 2005)

R

RKT

(Web Developer Express 2005, CSharp, C#)

I've searched high and low...

If have the typical _Default page. In it is a MultiView that contains
another MultiView - in both of those are Views containing my specialized
UserControls.

In any of those views, I need to acess the _Default page (parent, several
times removed). I would like a strongly typed mechanism, but at this point,
would settle to downcast it.

But I can't seem to be able to use it's 'type' in an expression without the
compiler complaint that the type is not known.

I have tried various efforts to define, reference or import the namespace
including the @Directives in the .ascx files. The only mechanism that seems
valid results in a complaint of circular reference.

(Have seen MasterPage-related directive that may work, but not using that
architecture (yet...))

Is there a prescribed method to do this?
 
T

Teemu Keiski

Hi,

see this:

Understanding Page Inheritance in ASP.NET 2.0
http://west-wind.com/weblog/posts/3016.aspx

The solution is described almost at end of the post.

Summarized:

- Create a base class for your _Default Page (class inheriting from
System.Web.UI.Page) and place it in App_Code
- make your _Default page to inherit from thios base page class
- When accessing the Page from user control, use Control's own Page property
but cast to the base type
 
T

Teemu Keiski

And to add,

there's also "Implementing Base Pages" thread in this newsgroup (started Jan
21st) where I have demonstrated the mechanism you could also apply.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top