You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
I'm on Chapter 7 (page 255 C#) and am getting the error listed below when attempting to view the default.aspx page in the browser. It started happening right when I added the "switch (Page.Theme.ToLower())" in the master page behind code. Specifically the line "TreeView1.Visible = true;" is causing the error. Any ideas? Everything was working fine up till this point.
Thanks in advance.
Server Error in '/' Application.
Object reference not set to an instance of an object.
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.
Line 35: case "darkgrey":
Line 36: Menu1.Visible = false;
Line 37: TreeView1.Visible = true;
Line 38: break;
Line 39: default:
Source File: c:\Documents and Settings\Home\My Documents\Visual Studio 2008\WebSites\WebSite1\MasterPages\MasterDemo.mast er.cs Line: 37
[NullReferenceException: Object reference not set to an instance of an object.]
MasterPages_MasterDemo.Page_Load(Object sender, EventArgs e) in c:\Documents and Settings\Home\My Documents\Visual Studio 2008\WebSites\WebSite1\MasterPages\MasterDemo.mast er.cs:37
System.Web.Util.CalliHelper.EventArgFunctionCaller (IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object sender, EventArgs e) +33
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436
public partial class MasterPages_MasterDemo : System.Web.UI.MasterPage
protected void Page_Load(object sender, EventArgs e)
string selectedTheme = Page.Theme;
HttpCookie preferredTheme = Request.Cookies.Get("PreferredTheme");
Right after posting the source code I found the problem... It was due to me putting the TreeView1 into the ContentPlaceHolder of the master page. Thanks for your quick reply! You did a fantastic job on this book. I took some very expensive technical training for ASP and tried various other ASP.NET books and didn't get much out of it. This book blows them away. Could have saved a bunch of money :)
quote:You did a fantastic job on this book. I took some very expensive technical training for ASP and tried various other ASP.NET books and didn't get much out of it. This book blows them away. Could have saved a bunch of money :)
Spread the word, spread the word. That's exactly the kind of feedback I am writing my books for .... ;)