Wrox Programmer Forums
|
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
 
Old July 4th, 2010, 10:43 AM
Authorized User
 
Join Date: Jun 2010
Posts: 27
Thanks: 8
Thanked 0 Times in 0 Posts
Default Applying a user selected theme

In Chapter 6 page 231(Try it out):

I am not getting any errors, the problem is the browser is not able to display the theme i choose form the dropdown list. It does not display the combination of both themes as mentioned in the book.

I have already removed the styleSheetTheme attribute but browser displays the default as in the web.config file beteen page element.

Can someone help me out with this one please.

Thanks in advance for your help.

Tariq
 
Old July 4th, 2010, 10:52 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Tariq,

Is the page you use to try this out inheriting your own BasePage? And how does the code for the BasePage look?

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 July 4th, 2010, 12:37 PM
Authorized User
 
Join Date: Jun 2010
Posts: 27
Thanks: 8
Thanked 0 Times in 0 Posts
Default Re: Applying a user selected theme

Thanks very much for the quick reply;

I am quite sure that it is inheriting from the BasePage, i could be wrong.
Here is the code for the base page:

using System;
using System.Web;

public class BasePage : System.Web.UI.Page
{

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

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.");
}
}
public BasePage()
{
this.PreRender += new EventHandler(Page_PreRender);
this.PreInit += new EventHandler(Page_PreInit);
}
}


And theme in the browser is what ever is in my configration file which looks like this.

configuration>

<system.web>
<pages theme="DarkGrey"></pages>
<compilation debug="false" targetFramework="4.0" />
</system.web>

</configuration>

As this is DarkGrey now so browser displays the dark gray if it was Monochrome browser displays the Monochorme and brower does not displays the theme i select form the dropdown list.

Tariq

Last edited by tariq; July 4th, 2010 at 12:40 PM..
 
Old July 4th, 2010, 12:56 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 Tariq,

Take a look at this:

HttpCookie preferredTheme = Request.Cookies.Get("PrererredTheme");

You're reading a cookie called PrererredTheme instead of PreferredTheme.

If you haven't made the same spelling mistake in the page that sets the coookie, you're reading a cookie you never set....

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 July 4th, 2010, 01:52 PM
Authorized User
 
Join Date: Jun 2010
Posts: 27
Thanks: 8
Thanked 0 Times in 0 Posts
Default Re:Applying a user selected theme

That was it. just the spelling mistake.

Thaks for helping me out, i will check the spelling first before disturbing you.

Thaks again.

Tariq





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
Applying the User-Selected Theme Kerblamalot BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 January 29th, 2010 11:08 AM
Ch 6 - User-Selected theme not working jennyWren BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 16 December 21st, 2009 03:52 PM
(Chapter 6) applying user-selected theme in IE7 phoenixx ASP.NET 3.5 Basics 6 August 26th, 2008 09:49 AM
Chapter 6 User-Selected Theme Question jabo2099 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 August 21st, 2008 03:45 AM





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