473,808 Members | 2,838 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Object loaded in Page & UserControl... not sure if i"m doing this right...

AC
I have a page class that inherits the System.Web.UI.P age class. Essentially what it does is load a user profile from a session (if it isn't loaded, it loads it into the session) and exposes it via a public property. This works just fine.

I have user controls that require the profile as well and I was coding it to work in the same way (created a class that inherits the System.Web.UI.U serControl class. It does the exact same thing as the page class I created.

My question is I'm wondering if I'm doing more owrk than is necessary. Can the UserControl see the page object? If it can, what's the execution order (would the control execute before the page so the user control wouldn't have access to the profile)?

Thanks in advance.

Nov 18 '05 #1
1 1224
A UserControl object exposes a Page attribute, which you can use to get a
reference to the hosting page. If you initialize your variable in your
OnInit event handler of your page, and then read it in your OnLoad event
handler of your control, you should be fine.

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"AC" <sp**@aNOSPAMME connell.com> wrote in message
news:eL******** ********@TK2MSF TNGP11.phx.gbl. ..
I have a page class that inherits the System.Web.UI.P age class. Essentially
what it does is load a user profile from a session (if it isn't loaded, it
loads it into the session) and exposes it via a public property. This works
just fine.

I have user controls that require the profile as well and I was coding it to
work in the same way (created a class that inherits the
System.Web.UI.U serControl class. It does the exact same thing as the page
class I created.

My question is I'm wondering if I'm doing more owrk than is necessary. Can
the UserControl see the page object? If it can, what's the execution order
(would the control execute before the page so the user control wouldn't have
access to the profile)?

Thanks in advance.
Nov 18 '05 #2

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

Similar topics

0
1538
by: Matt Howeson | last post by:
I have a problem with a usercontrol that is dynamically loaded, from a web control and is not restoring it's viewstate properly. Here's the scenario. Within our content management system, I have a webcontrol which allows a admin user to select a usercontrol to include within a page when in "edit mode". When a user is editing the page they see a dropdown list of available controls and select one and save the page, kind of irrelevant to...
2
1983
by: N. Demos | last post by:
I have a user control with code behind of which two instances are created/declared in my aspx page. The aspx page has code behind also, as I need to access methods of the usercontrols on page submit. I've read several post here and articles on the web on this topic. What little I have learned from them is that you have to pre-compile the usercontrol in order to access it in the aspx code behind. I did this, compiling the usercontrol...
2
1625
by: tlk | last post by:
Hi, everyone. I'm having a problem that I hope some more experienced developers can help me figure-out. We have a project called Records that has been around for a year or so. We're currently coding an add-on to this project called Lessons. In creating Lessons we're obviously trying to re-use existing code from Records. And, of course, for political reasons I'm not free to make any changes to Records. The project Records contains a...
3
4319
by: j-in-uk | last post by:
I have 3 pages Site.master, Album.aspx and ContinentsMenu.ascx. Continents is a usercontrol placed in Albums. In Album.aspx.cs I need to access a property from the Continents usercontrol and is done using the code below. When I add masterpages to Album.aspx and remove all the html tags I get the error System.NullReferenceException: Object reference not set to an instance of an object. for the highlighted yellow line below. I notice once I...
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9600
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10373
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10374
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9195
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5685
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3859
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.