473,399 Members | 3,106 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,399 software developers and data experts.

Backwards Inheritence In Web User Controls


For a c# web application, I created a user control that includes a form in
control.

The idea is, on the main Page, when the user clicks Submit from
the master form, that makes the user control visible and gives
it new functionality, but retains the look of the top half of
the master page. I then hide the original submit button.

Ok, now, after pressing the Submit button in the user control, I want
to change the look of the master page.

The questions are:

(0) how do I gain access to the properties of the Page that
instantiates the user control, from the user control itself?

(1) Is some kind of upwards/backwards inheritence is necessary?

(2) Or do I pass the whole Page as an object to the click event?
Jul 21 '05 #1
5 2404
0) There is a Page property of the UserControl class (which you are
inheriting from) that gives you a reference to the instantiating page.
1) Huh? What does this mean?
2) I take it this is related to the first question? In which case that's the
answer.

"john bailo" <ja*****@earthlink.net> wrote in message
news:f0******************************@news.teranew s.com...

For a c# web application, I created a user control that includes a form in
control.

The idea is, on the main Page, when the user clicks Submit from
the master form, that makes the user control visible and gives
it new functionality, but retains the look of the top half of
the master page. I then hide the original submit button.

Ok, now, after pressing the Submit button in the user control, I want
to change the look of the master page.

The questions are:

(0) how do I gain access to the properties of the Page that
instantiates the user control, from the user control itself?

(1) Is some kind of upwards/backwards inheritence is necessary?

(2) Or do I pass the whole Page as an object to the click event?

Jul 21 '05 #2
On Wed, 17 Sep 2003 13:12:23 -0400, Marina wrote:
0) There is a Page property of the UserControl class (which you are
inheriting from) that gives you a reference to the instantiating page.


When I enter Page, intellisense seems to show a
generic Page object -- but I want to control the
actual calling object along with its specific
properties ( such as text boxes, tables ) and so
on.

Can I just assume "Page" will take on those properties
at run time? Is Page like window.opener() ( the Parent )
in javascript?
Jul 21 '05 #3
"john bailo" <ja*****@earthlink.net> wrote in message news:<36******************************@news.terane ws.com>...
On Wed, 17 Sep 2003 13:12:23 -0400, Marina wrote:
0) There is a Page property of the UserControl class (which you are
inheriting from) that gives you a reference to the instantiating page.


When I enter Page, intellisense seems to show a
generic Page object -- but I want to control the
actual calling object along with its specific
properties ( such as text boxes, tables ) and so
on.

Can I just assume "Page" will take on those properties
at run time? Is Page like window.opener() ( the Parent )
in javascript?


Say your code-behind class file for the Page is called 'MyPage', then
you should be able to cast the Page property from the usercontrol like
so:

MyPage myPage = this.Page as MyPage;

If you wanted to access the properties of the page, you will need to
change them to public as opposed to private or protected, then they
will show up in intellisense on the myPage object.

Alternatively, you can use Page.FindControl. Say you have a textbox
called 'MyTextBox' on the page, you can access it like so:

TextBox myTextBox = Page.FindControl("MyTextBox") as TextBox;

Regards,
Paddo
Jul 21 '05 #4
Genius!

Thanks, Paddo....
"Paddo" <pa***@bigpond.net.au> wrote in message
news:d4**************************@posting.google.c om...
"john bailo" <ja*****@earthlink.net> wrote in message

news:<36******************************@news.terane ws.com>...
On Wed, 17 Sep 2003 13:12:23 -0400, Marina wrote:
0) There is a Page property of the UserControl class (which you are
inheriting from) that gives you a reference to the instantiating page.


When I enter Page, intellisense seems to show a
generic Page object -- but I want to control the
actual calling object along with its specific
properties ( such as text boxes, tables ) and so
on.

Can I just assume "Page" will take on those properties
at run time? Is Page like window.opener() ( the Parent )
in javascript?


Say your code-behind class file for the Page is called 'MyPage', then
you should be able to cast the Page property from the usercontrol like
so:

MyPage myPage = this.Page as MyPage;

If you wanted to access the properties of the page, you will need to
change them to public as opposed to private or protected, then they
will show up in intellisense on the myPage object.

Alternatively, you can use Page.FindControl. Say you have a textbox
called 'MyTextBox' on the page, you can access it like so:

TextBox myTextBox = Page.FindControl("MyTextBox") as TextBox;

Regards,
Paddo

Jul 21 '05 #5
On Fri, 19 Sep 2003 20:00:03 -0700, Paddo wrote:
MyPage myPage = this.Page as MyPage;

If you wanted to access the properties of the page, you will need to
change them to public as opposed to private or protected, then they
will show up in intellisense on the myPage object.

Alternatively, you can use Page.FindControl. Say you have a textbox
called 'MyTextBox' on the page, you can access it like so:

TextBox myTextBox = Page.FindControl("MyTextBox") as TextBox;


Paddo:

I used your method with great success; and I
don't mean to look a gift horse in the mouth;
however, from an OOP standpoint, it still doesn't
make any sense to me.

I think of a User Control as being instantiated
by the Page to begin with. To then, instantiate
a new this.Page to me would mean instantiating
a different object from the object that called
the User Control.

How can it be, that instantiating a new 'copy'
of the MyPage object allows me to gain access
to the properties and methods of the original
myPage, the one that called the User Control ?
Jul 21 '05 #6

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

Similar topics

7
by: preetam | last post by:
Hi, This question is more towards design than towards c++ details. By looking at books on design patterns and various google threads on the same topic, I see that composition is favoured to...
5
by: john bailo | last post by:
For a c# web application, I created a user control that includes a form in control. The idea is, on the main Page, when the user clicks Submit from the master form, that makes the user control...
2
by: jqpdev | last post by:
How does one sub-class user controls within VS.NET 2003?
1
by: Mark | last post by:
Hopefully somebody can help me with this very frustrating problem. In Dreamweaver I have a template page and a page created from this template called Home.aspx. In Visual Studio I have a class...
150
by: tony | last post by:
If you have any PHP scripts which will not work in the current releases due to breaks in backwards compatibility then take a look at http://www.tonymarston.net/php-mysql/bc-is-everything.html and...
5
by: Neelesh Bodas | last post by:
This might be slightly off-topic. Many books on C++ consider multiple inheritence as an "advanced" concept. Bruce Eckel says in TICPP, volume 2 that "there was (and still is) a lot of...
7
by: Alan T | last post by:
Can someone tell me how to create a form inherit from another form ? In my project, I have created a form with buttons and groupbox to be used as ancestor, how to create a form inherit from this...
11
by: Wayne Pedersen | last post by:
Need some help - and I may be doing this wrong, so please correct and suggest! I'm learning the MVP method, which I seem to have a good grasp of. Now I am trying something a bit more advanced. ...
0
by: chromis | last post by:
Hi, I'm creating virtual tour of a house, the part I am working on at the moment involves a 360 spin view of the house (a series of 36 flat frames). Each corner of the house has a hotspot so that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.