473,405 Members | 2,373 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Problem with user control on ASP.NET 2.0

Is it possible for a user control on a webform to access the base class(another
webfrom) of the host page ?

e.g my code does something like this:
ChildPage inherits from ParentPage

and a function in the code behind of a user control hosted on ChildPage does
this
ParentPage p = (ParentPage)this.Page;
p.SomeFunction();
This used to work fine on ASP.NET 1.1 but gives errors on ASP.NET 2.0 beta
2 june ctp. Most probably this is due to the new compilation model. Any solutions
or workaround?

Also is it possile to just access the host page in the code beside of a user
control, something like this:

(based on the above scenario)

ChildPage p = this.Page;

p.SomeOtherFunction();

would asp.net 2.0 complain about this too and if yes how to do something
like this in 2.0 ?

-Ahmed


Nov 19 '05 #1
2 1205
Hi Ahmed,

Welcome to MSDN newsgroup.
As for the casting page error you mentioned, here are some of my
understanding:

1. For class casting, as long as the underlying instance is of the certain
class, we can surely cast it to that type's reference. I suggest you first
using the object.GetType().ToString() to dump out the UserControl.Page's
actual type to see whether that's your expected one.

2. As for the parent/ child page, do you mean the normal class inheritance
in c# , just like:

class ParentPage
{
..........
}
class ChildPage: Parent Page
{
........
}

or the MasterPage in ASP.NET 2.0? If you're using the MasterPage, I'm
afraid you can't using the type casting because MasterPage isn't
implemented by simplly using the .NET class's inheritance. The concrete
page class isn't acutally derived from the MasterPage.

In addition, for ASP.NET 2.0 problems, I'd suggest you try posting in the
MSDN web forum since there're many experienced community members or ASP.NET
develop team's guys there.

http://forums.microsoft.com/msdn/

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #2
Hi Steven

I am developing an asp.net application using c# and asp.net 2.0 beta 2. I
started developing this page usign beta1. In beta 1 I have written some code
in Page_LoadComplete(object sender, EventArgs e) events of page. It was
working fine. But after I installed beta 2.0 Page_LoadComplete events is not
firing at all. Can u guide me how can I achieve this goal?

Thankx in advance.
Shailesh.

"Steven Cheng[MSFT]" wrote:
Hi Ahmed,

Welcome to MSDN newsgroup.
As for the casting page error you mentioned, here are some of my
understanding:

1. For class casting, as long as the underlying instance is of the certain
class, we can surely cast it to that type's reference. I suggest you first
using the object.GetType().ToString() to dump out the UserControl.Page's
actual type to see whether that's your expected one.

2. As for the parent/ child page, do you mean the normal class inheritance
in c# , just like:

class ParentPage
{
..........
}
class ChildPage: Parent Page
{
........
}

or the MasterPage in ASP.NET 2.0? If you're using the MasterPage, I'm
afraid you can't using the type casting because MasterPage isn't
implemented by simplly using the .NET class's inheritance. The concrete
page class isn't acutally derived from the MasterPage.

In addition, for ASP.NET 2.0 problems, I'd suggest you try posting in the
MSDN web forum since there're many experienced community members or ASP.NET
develop team's guys there.

http://forums.microsoft.com/msdn/

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rhy Mednick | last post by:
I'm creating a custom control (inherited from UserControl) that is displayed by other controls on the form. I would like for the control to disappear when the user clicks outside my control the...
5
by: | last post by:
Hi, I'm trying to use the cookie munging session handling behaviour of asp.net instead of cookies themselves as I'm finding quite a few people are barring cookies (especially AOL users). If I...
1
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am have facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the...
9
by: Anders K. Jacobsen [DK] | last post by:
Hi I have this that adds some usercontrol (UCTodays.ascx) to a placeholder foreach(A a in B){ UCTodays ucline = (UCTodays )LoadControl("UCTodays.ascx");...
5
by: Segfahlt | last post by:
I need a little help here please. I have 2 win forms user controls in 2 different projects that I'm hosting in 2 different virtual directories. The controls have been test and operate okay in...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.