473,402 Members | 2,053 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,402 software developers and data experts.

Master Pages and Usercontrols - object reference not set

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.in the line marked ******
below. I notice once I insert the following line back<!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"back to the Album.aspx
page and remove the masterpage references it works fine. Any ideas on
how i can access my usercontrol using masterpages?

private ContinentsMenu _continentList;

override protected void OnInit(System.EventArgs e)
{base.OnInit(e);
InitializeComponent();
_continentList = ((ContinentsMenu)(FindControl("ContinentsMenu1"))) ;
}

protected void Page_Load(object sender, System.EventArgs e)
******{_albumPath = Path.Combine(_photosPath,
_continentList.SelectedContinent);}

Aug 14 '06 #1
1 2541
ContinentsMenu _continentList =
(ContinentsMenu)Master.FindControl("ContinentsMenu 1");

<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/

"j-in-uk" <je******@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
>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.in the line marked ******
below. I notice once I insert the following line back<!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"back to the Album.aspx
page and remove the masterpage references it works fine. Any ideas on
how i can access my usercontrol using masterpages?

private ContinentsMenu _continentList;

override protected void OnInit(System.EventArgs e)
{base.OnInit(e);
InitializeComponent();
_continentList = ((ContinentsMenu)(FindControl("ContinentsMenu1"))) ;
}

protected void Page_Load(object sender, System.EventArgs e)
******{_albumPath = Path.Combine(_photosPath,
_continentList.SelectedContinent);}

Aug 14 '06 #2

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

Similar topics

9
by: Andy | last post by:
Hey all, I'm building out my first project using asp.net v2.0 master pages. It seems that when you use master pages and try to reference document.body.scrollTop it allways = zero/0. The same code...
17
by: Rob R. Ainscough | last post by:
Again another simple concept that appears NOT to be intuitive or I'm just stupid. I've read the WROX book and the example doesn't actually show how the .master page links in the other content...
0
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...
8
by: JT | last post by:
Hi, I have done a fair amount of style editing inline in ASP. I'm now using VS 2005 with a standard web project (not Web Application Project). This is my first foray into CSS in a style sheet...
2
by: n# | last post by:
I have an old existing website with a Header/ Left Hand Menu and a iframe as the main body content, adjacent to the menu. So for every click on the menu item, I used to load a aspx page on the...
0
by: Daniel Magliola | last post by:
I'm having a weird behaviour when implementing localization resource files in my website. This looks like a .Net bug to me, but it's too obvious to be there, so I must be overlooking something. ...
13
by: Kirk | last post by:
I have been reading Scott Allen's article on Master Pages (http:// odetocode.com/Articles/450.aspx) but I am having problems understanding a concept. Specifically, I have created a property...
10
by: Cirene | last post by:
I know that sometimes referring to controls deep in a page using a Master Page can be funky. For a website using a standard header/footer/nav, do you prefer using User Controls for the common...
10
by: =?Utf-8?B?RGFuaQ==?= | last post by:
Hi, Trying to create a master page that holds a menu, and the menu switches between pages in the site. 2 problem arrosed: a. When I navigate from page to page (all AJAX Web Forms, with the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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.