 |
BOOK: Beginning ASP.NET 4 : in C# and VB
 | This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|
|

October 2nd, 2010, 04:33 PM
|
|
Registered User
|
|
Join Date: Sep 2010
Posts: 5
Thanks: 4
Thanked 1 Time in 1 Post
|
|
System.NullReferenceException was unhandled by user code - Chapter 8
I created my first user control and getting this error. I took it out and im STILL getting the error. This worked fine 2 days ago, not sure what happened. Trying to run the general Planet Wrox site. Please help. Thanks!
Here is the error:
System.NullReferenceException was unhandled by user code
Message=Object reference not set to an instance of an object.
Source=App_Web_3f3iysao
StackTrace:
at MasterPages_Frontend.Page_Load(Object sender, EventArgs e) in c:\BegASPNET\mystie\MasterPages\Frontend.master.cs :line 25
at System.Web.Util.CalliHelper.EventArgFunctionCaller (IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
Here is the code that its happening on (within the page load):
switch (Page.Theme.ToLower()) //error happening here
{
case "darkgrey":
Menu1.Visible = false;
TreeView1.Visible = true;
break;
default:
Menu1.Visible = true;
TreeView1.Visible = false;
break;
}
|
|

October 3rd, 2010, 06:09 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
If you get an error on this code: Page.Theme.ToLower() my guess is that the Theme property is null. Are you you set one on the <pages /> element in web.config?
Imar
|
|
The Following User Says Thank You to Imar For This Useful Post:
|
|
|

October 3rd, 2010, 05:04 PM
|
|
Registered User
|
|
Join Date: Sep 2010
Posts: 5
Thanks: 4
Thanked 1 Time in 1 Post
|
|
Imar,
That worked! thanks a lot for responding so fast. Is there something I might have done accidentally that would have removed that?? Love the book.
|
|

October 4th, 2010, 02:17 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Not really. Maybe you cut it away to test something out, or maybe you're using a different web.config file than you previously were....
Imar
|
|
The Following User Says Thank You to Imar For This Useful Post:
|
|
|

October 4th, 2010, 11:24 AM
|
|
Registered User
|
|
Join Date: Sep 2010
Posts: 5
Thanks: 4
Thanked 1 Time in 1 Post
|
|
ok great. THANKS!!! 
|
|

October 4th, 2010, 11:33 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
In that case, please use the Thanks button below each post you feel happy about.... ;-)
Imar
|
|
The Following User Says Thank You to Imar For This Useful Post:
|
|
|

October 4th, 2010, 11:48 AM
|
|
Registered User
|
|
Join Date: Sep 2010
Posts: 5
Thanks: 4
Thanked 1 Time in 1 Post
|
|
sorry! new to the forums, just "thanked" you.
|
|
The Following User Says Thank You to dtmmaxx For This Useful Post:
|
|
|

September 1st, 2011, 05:20 PM
|
|
Registered User
|
|
Join Date: Sep 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Why should I have to set the theme in the web.config file? The switch themes logic doesn't work anymore. It used to work before I created the user control in chapter 8. Why does that cause the theme switching to be in error?
Mollie
|
|

September 1st, 2011, 05:33 PM
|
|
Registered User
|
|
Join Date: Sep 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
In another forum, we were told to remove the <pages> control from the web.config file so that the Dark Grey style theme would work correctly.
Mollie
|
|

September 1st, 2011, 05:45 PM
|
|
Registered User
|
|
Join Date: Sep 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Curiously, the error disappeared when site-wide registration was employed. I tried using the pages directive without the theme; that works fine. What is going on?
Mollie
|
|
 |
|