MasterPage Question

Joined
Jan 10, 2007
Messages
43,898
Location
In The Machine
publicpartialclassmp_main : System.Web.UI.MasterPage
{
protectedvoid Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Page.Title =
Blog.Title;
Title.Text =
Blog.Title;
Subtitle.Text =
Blog.Subtitle;
}
}
}

When it reaches Title.Text assignment gives a null reference exception. I know its able to pull the Title back from the data access layer because the Page Title setting was my informal unit test. So if not during page load when should one set such things in a Master Page :) Any ideas.

For curious: Blog is a DataAccess layer factory that pulls from a memory resident XDocument which is loaded during AppStart and anytime changes are made to the config.


static
publicstring Title
{
get
{
return _config.Root.Element("title").Element("main").Value;
}
}

*
Server Error in '/Blog' Application.

Object reference not set to an instance of an object.

[FONT=Arial, Helvetica, Geneva, SunSans-Regular, sans-serif]Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 20: { Line 21: Page.Title = Blog.Title; Line 22: Title.Text = Page.Title; Line 23: Subtitle.Text = Blog.Subtitle; Line 24: }
Source File: d:\WebProj\Blog\config\mp\main.master.cs ** Line: 22

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.] mp_main.Page_Load(Object sender, EventArgs e) in d:\WebProj\Blog\config\mp\main.master.cs:22 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +47 System.Web.UI.Control.LoadRecursive() +131 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436

Version Information:*Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433 [/FONT]


More...

View All Our Microsft Related Feeds
 
Back
Top