Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

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 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 August 4th, 2010, 11:49 AM
Registered User
 
Join Date: Jul 2010
Posts: 15
Thanks: 6
Thanked 0 Times in 0 Posts
Default Please clarify this in Chapter 6 (pages 226-232)

Hello,
I typed in the code as given so that the user may choose "Monochrome" or "DarkGrey". My question is this: What should the value of the pages theme be in the <pages></pages> element in the the web.config file between the <system.web> and </system.web> tags. Should it be <pages theme ="Monochrome"></pages> or <pages theme ="DarkGrey"></pages>. I have the DropDownList Box as recommened and the code thereafter in order to make it functional based on the SelectedIndexChanged event.

The specific try out that is not working is that on page 231.(Applying the User-selected Theme) Despite having everything in from Pages 226 to 232 as instructed in the book,whenever I select either "Monochrome" or "DarkGrey" all I can see is the "DarkGrey" theme.

I removed the styleSheet theme from the <pages> element (as recommended on Page 231 - last paragraph) and also have "AutoPostBack" for the Drop-down list set to TRUE.

Can anyone please help me see where I am going wrong. What is confsuing me is what value for "theme" should I have in the web.config file in the <pages> element?
 
Old August 4th, 2010, 12:42 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

What you assign in web.config doesn't really mater; it only serves as a default for users who haven't chosen a theme explicitly.

My guess is that a) your test page does not inherit BasePage, or the code in the BasePage is not correct.

Can you post the code behind of the web form and the code for the BasePage class?

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!
The Following User Says Thank You to Imar For This Useful Post:
pennkaiser (August 4th, 2010)
 
Old August 4th, 2010, 01:28 PM
Registered User
 
Join Date: Jul 2010
Posts: 15
Thanks: 6
Thanked 0 Times in 0 Posts
Default Will follow up right now and let you know

Hello again,
Thanks for the Quick reply. I just progressed in the chapter and came across a another issue. However I will discuss this later. For now, I am going to do the things you asked me to do and post back to this particular thread. Soon then,
 
Old August 4th, 2010, 01:50 PM
Registered User
 
Join Date: Jul 2010
Posts: 15
Thanks: 6
Thanked 0 Times in 0 Posts
Default Code in BasePage.cs and Default.aspx

Hi
Here is the code for my BasePage.cs file in App_Code Folder
//============================================
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for BasePage
/// </summary>
public class BasePage: System.Web.UI.Page
{

    private void Page_PreRender(object sender, EventArgs e)
    {
        if (this.Title == "Untitled Page" || string.IsNullOrEmpty(this.Title))
        {
            throw new Exception("Page title cannot be \"Untitled Page\" or an empty string.");
        
        }
  
    }

    private void Page_PreInit(object sender, EventArgs e)
    {
        HttpCookie preferredTheme = Request.Cookies.Get("PreferredTheme");
        if (preferredTheme != null)
        {
            Page.Theme = preferredTheme.Value;
            
        }
    
    }



	public BasePage()
	{
        this.PreRender += new EventHandler(Page_PreRender);
        this.PreInit += new EventHandler(Page_PreInit);
	}
}
//================================================== ======
Here is the code for the Default.aspx page that is supposed to allow the user to select either theme, that then needs to be applied

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}
 
Old August 4th, 2010, 01:59 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

That looks fine, and pretty much as it should. So, it must be something in the base page,.

Can you post the markup and Code Behind? Maybe you named the cookie differently there?

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!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 6 pps 226-228 User Selected Theme Featheriver BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 April 20th, 2011 07:08 AM
Problem: Chapter 7 "Creating and Using an Earthquake Content Provider" (Page 232) DrGaribaldi BOOK: Professional Android 2 Application Development 0 June 17th, 2010 04:07 AM
RS-232 and Access 2007 VBA database Gajun BOOK: Beginning Access 2007 VBA ISBN: 978-0-470-04684-5 1 June 2nd, 2010 11:08 AM
Error in GetEaster method on page 226 peryan77 BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 1 November 20th, 2009 12:36 PM
RS-232 serial communications Mitch Access 1 April 23rd, 2004 07:50 PM





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