Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4.5 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-31180-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5 : 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
 
Old April 1st, 2014, 01:27 AM
Registered User
 
Join Date: Mar 2014
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch 6 Stuck on the DDL for Themes

Hi,

I really don't want to bother Imar, so if anybody can help me that would be great as well.

OK I completed the exercise on page 229 successfully and viewed the 2 themes. The problem started on page 239 when I added the drop down list. It won't switch.

AutoPostBack is on, I see the page refresh, and I hit PF5 anyway just in case.
I see themes applied inside the <head> tags. I'm getting the same results in IE and FireFox, I never change cookie settings.

To eliminate the possibility of a syntax error in Frontend.master.cs I copied the code from the download. I got the same results.

The default setting is working correctly, so I assume Web.config is correct.

http://i1171.photobucket.com/albums/...ps1a0fa8f5.jpg

http://i1171.photobucket.com/albums/...ps456d45cc.jpg

I'm quite new at this, if you can point me in the proper direction I'd be grateful. I guess I will read Chapter 18 next.

Regards,
Aris
 
Old April 1st, 2014, 07:14 AM
Authorized User
 
Join Date: Mar 2014
Posts: 13
Thanks: 2
Thanked 0 Times in 0 Posts
Default

As I can see, you forgot the switch statement:

Code:
if (!Page.IsPostBack)
        {
            string selectedTheme = Page.Theme;
            HttpCookie preferredTheme = Request.Cookies.Get("PreferredTheme");
            if (preferredTheme != null)
            {
                selectedTheme = preferredTheme.Value;
            }
            if (!string.IsNullOrEmpty(selectedTheme))
            {
                ListItem item = ThemeList.Items.FindByValue(selectedTheme);
                if (item != null)
                {
                    item.Selected = true;
                }
            }
        }

        switch (Page.Theme.ToLower())
        {
            case "darkgrey":
                Menu1.Visible = false;
                TreeView1.Visible = true;
                break;
            default:
                Menu1.Visible = true;
                TreeView1.Visible = false;
                break;
        }
 
Old April 1st, 2014, 10:51 AM
Registered User
 
Join Date: Mar 2014
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you but I have not reached the Menu Chapter yet. It seems that's where this code is added, no? I see this code in Chapter 7, a bit after where I am stuck.

Regards,
Aris
 
Old April 1st, 2014, 01:53 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Did you follow the exercise that applies the theme? In that exercise you create a file called BasePage.cs / vb that applies the theme.

Hope this helps,

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!
 
Old April 1st, 2014, 05:38 PM
Registered User
 
Join Date: Mar 2014
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar. Yes I completed the "creating a base page" how-to on page 221.

http://i1171.photobucket.com/albums/...ps36df8672.jpg

Step 6 says to repeat steps 3 and 5 for all site pages, I'm assuming here the default and the login page are all of them. Here they are:

http://i1171.photobucket.com/albums/...ps24ab484d.jpg

http://i1171.photobucket.com/albums/...ps4d6621a7.jpg

Thanks for replying, I regret having to bother you for this.
Aris
 
Old April 1st, 2014, 06:21 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Your BasePage doesn't have code to apply the theme. Looks like you missed the Try It Out exercise that applies the theme. It is in the same chapter. Also, the first exercise that modifies the master page should have a note that explains things won't work until you complete the second exercise.

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!
 
Old April 1st, 2014, 10:37 PM
Registered User
 
Join Date: Mar 2014
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Resolved. I will double check the downloads before I ask any more questions.

Ugh, my error? I was at the end of the prior try-it-out and I didn't read the last 2 sentences in the last step. Too anxious to move fast.

Thank you for your time.

Last edited by Aristide; April 1st, 2014 at 10:47 PM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Editable ddl? FOD ASP.NET 4 General Discussion 0 May 31st, 2011 10:37 PM
XmlDataSource DDL and Gridview rthomson77@hotmail.com XML 4 January 21st, 2009 10:57 AM
how can selectedvalue of DDL make other DDL visibl hertendreef ASP.NET 2.0 Professional 4 May 20th, 2008 04:38 PM
DDL error cmw231 ASP.NET 2.0 Basics 2 July 17th, 2006 08:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.