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 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
Reply With Quote
  #2 (permalink)  
Old July 4th, 2010, 10:52 AM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 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!
Reply With Quote
  #3 (permalink)  
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..
Reply With Quote
  #4 (permalink)  
Old July 4th, 2010, 12:56 PM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 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!
Reply With Quote
  #5 (permalink)  
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
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
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



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


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