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
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 December 5th, 2010, 07:31 PM
Authorized User
 
Join Date: Dec 2010
Posts: 22
Thanks: 10
Thanked 0 Times in 0 Posts
Default Theme switching won't "stick"

I've setup the DropDown box to switch themes, but what happens is the Monochrome theme displays, I select DarkGrey, the page reloads, then the theme and the DropDown box both revert to monochrome.

I've zipped up my site and put it in a Google Doc:

Zip file of site is here.

TIA

--
Knute
Reply With Quote
  #2 (permalink)  
Old December 6th, 2010, 05:21 AM
Imar's Avatar
Wrox Author
Points: 72,022, Level: 100
Points: 72,022, Level: 100 Points: 72,022, Level: 100 Points: 72,022, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,076
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Knute,

You forgot to add the cookie you created to the Cookies collection in the ThemeList_SelectedIndexChanged method. It's the bold line in the following code block:

Code:
 
HttpCookie preferredTheme = new HttpCookie("PreferredTheme");
preferredTheme.Expires = DateTime.Now.AddMonths(3);
preferredTheme.Value = ThemeList.SelectedValue;
Response.Cookies.Add(preferredTheme);
Response.Redirect(Request.Url.ToString());
Once you fix that, you'll get an error about the theme DarkGrey not being found. That's because your theme folder is called Dark_Grey, not DarkGrey. Once you fix that as well, the theme switcher works.

Cheers,

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:
ksnortum (December 6th, 2010)
  #3 (permalink)  
Old December 6th, 2010, 05:24 AM
Authorized User
 
Join Date: Oct 2009
Posts: 22
Thanks: 2
Thanked 10 Times in 7 Posts
Default

The code in the Frontend.master

Code:
protected void ThemeList_SelectedIndexChanged(object sender, EventArgs e)
    {
      HttpCookie preferredTheme = new HttpCookie("PreferredTheme");
      preferredTheme.Expires = DateTime.Now.AddMonths(3);
      preferredTheme.Value = ThemeList.SelectedValue;
      Response.Redirect(Request.Url.ToString());
    }
is missing a

Code:
Response.Cookies.Add(preferredTheme);
which actually sets the cookie. You need this line just before you do the redirect.
Reply With Quote
The Following User Says Thank You to walbalooshi For This Useful Post:
ksnortum (December 6th, 2010)
  #4 (permalink)  
Old December 6th, 2010, 02:49 PM
Authorized User
 
Join Date: Dec 2010
Posts: 22
Thanks: 10
Thanked 0 Times in 0 Posts
Default I works

Thanks guys, that was it. Funny how I knew the cookie wasn't getting writen and I looked at that section of code but missed the .add() line.

The problems with "DarkGrey" versus "Dark_Grey" are in the book. You are told on page 227, step 3 of Try it Out to add DarkGrey (no underscore) to the DropDownList. I haven't looked in the errata but it seems like a candidate.

Thanks again.

--
Knute
Reply With Quote
  #5 (permalink)  
Old December 6th, 2010, 04:17 PM
Imar's Avatar
Wrox Author
Points: 72,022, Level: 100
Points: 72,022, Level: 100 Points: 72,022, Level: 100 Points: 72,022, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,076
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Quote:
You are told on page 227, step 3 of Try it Out to add DarkGrey (no underscore) to the DropDownList.
That's absolutely correct, but Dark_Grey with an underscore is nowhere to be found in the book ;-)

Cheers,

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
  #6 (permalink)  
Old December 6th, 2010, 06:52 PM
Authorized User
 
Join Date: Dec 2010
Posts: 22
Thanks: 10
Thanked 0 Times in 0 Posts
Default Dark_grey not found

I guess I imagined it. Thanks for looking.
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
Difficulties with "web.config" and "ASPNETDB" CFRham BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 2 July 3rd, 2010 10:19 AM
Need code corrections "get sub or function not defined" error" bluesboytoo Excel VBA 1 October 22nd, 2009 11:12 PM
How to theme the "Browse" button of "FileUpload" control? varunbwj BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 October 14th, 2009 01:22 AM
Add a CheckBox DataColumn to my DataGridView, Null format: "" or "True" but Error: F ismailc C# 2005 0 September 25th, 2009 04:56 AM
Code not going as planned: "icicle" vs "savedinstancestate" joopthecat BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 3 May 3rd, 2009 03:09 PM



All times are GMT -4. The time now is 04:04 PM.


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