Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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 .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 2nd, 2010, 04:33 PM
Registered User
 
Join Date: Sep 2010
Posts: 5
Thanks: 4
Thanked 1 Time in 1 Post
Default 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;
}
Reply With Quote
  #2 (permalink)  
Old October 3rd, 2010, 06:09 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

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
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
dtmmaxx (October 4th, 2010)
  #3 (permalink)  
Old October 3rd, 2010, 05:04 PM
Registered User
 
Join Date: Sep 2010
Posts: 5
Thanks: 4
Thanked 1 Time in 1 Post
Default

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.
Reply With Quote
  #4 (permalink)  
Old October 4th, 2010, 02:17 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

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
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
dtmmaxx (October 4th, 2010)
  #5 (permalink)  
Old October 4th, 2010, 11:24 AM
Registered User
 
Join Date: Sep 2010
Posts: 5
Thanks: 4
Thanked 1 Time in 1 Post
Default

ok great. THANKS!!!
Reply With Quote
  #6 (permalink)  
Old October 4th, 2010, 11:33 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Quote:
THANKS!!!
In that case, please use the Thanks button below each post you feel happy about.... ;-)

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
dtmmaxx (October 4th, 2010)
  #7 (permalink)  
Old October 4th, 2010, 11:48 AM
Registered User
 
Join Date: Sep 2010
Posts: 5
Thanks: 4
Thanked 1 Time in 1 Post
Default

sorry! new to the forums, just "thanked" you.
Reply With Quote
The Following User Says Thank You to dtmmaxx For This Useful Post:
Imar (October 4th, 2010)
  #8 (permalink)  
Old September 1st, 2011, 05:20 PM
Registered User
Points: 9, Level: 1
Points: 9, Level: 1 Points: 9, Level: 1 Points: 9, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #9 (permalink)  
Old September 1st, 2011, 05:33 PM
Registered User
Points: 9, Level: 1
Points: 9, Level: 1 Points: 9, Level: 1 Points: 9, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #10 (permalink)  
Old September 1st, 2011, 05:45 PM
Registered User
Points: 9, Level: 1
Points: 9, Level: 1 Points: 9, Level: 1 Points: 9, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ConstraintException was unhandled by user code jcooper0 BOOK: Professional ASP.NET MVC 2 8 February 16th, 2011 09:32 AM
HttpCompileException was unhandled by user code. error CS0246 fh84 BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 4 October 25th, 2010 12:49 PM
TargetInvocationException was unhandled by user code MattHoff BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio 2 October 13th, 2010 11:38 AM
System.NullReferenceException Michael YoeH ASP.NET 3.5 Professionals 0 October 19th, 2009 03:13 AM
System.NullReferenceException JayLou BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 1 April 6th, 2007 12:55 PM



All times are GMT -4. The time now is 12:53 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.