Master Pages & UserControls - object reference not set

Discussion in 'ASP .Net' started by j-in-uk, Aug 14, 2006.

  1. j-in-uk

    j-in-uk Guest

    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 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);}
    j-in-uk, Aug 14, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Doug McCann
    Replies:
    1
    Views:
    1,001
    William Brogden
    Aug 5, 2004
  2. Replies:
    1
    Views:
    3,198
    PeterKellner
    May 16, 2006
  3. j-in-uk
    Replies:
    1
    Views:
    814
    clintonG
    Aug 14, 2006
  4. Replies:
    0
    Views:
    513
  5. Replies:
    1
    Views:
    476
    Mark Rae [MVP]
    Sep 20, 2007
Loading...

Share This Page