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 July 30th, 2009, 06:35 PM
Authorized User
 
Join Date: Jul 2009
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Global Theme directory?

Hello Imar,

Is there a way to programmatically get all the Themes of a site? (I looked in the forum for this but I could not find it.)

For example I added a third theme called "Brown". I then added it to the dropDown ran the app and selected brown in the dropDown which created the cookie with my preferred theme. Then I closed the app deleted "Brown" from the dropDown and deleted the theme. So basically I decided to discontinue this theme. I still have brown in my preferredTheme cookie so I get an exception that says: Theme 'Brown' cannot be found in the application or global theme directories. Is the "global theme directories collection" a collection I can get to? (I can't find it anywhere.) The only way I can do it is via a string array and if it is not in the collection set it to the Page.Theme and I'm sure there is a better way. In the stack trace there was:System.Web.UI.Page.InitializeThemes() I thought I could put my code there and just do a try catch if failed then set it to Page.Theme, but I can't get to it.

I'm not sure where execution goes after this point:
Code:
private void Page_PreInit(object sender, EventArgs e)
  {
    HttpCookie preferredTheme = Request.Cookies.Get("PreferredTheme");
    if (preferredTheme != null)
    {
      Page.Theme = preferredTheme.Value;
    }
  }// Fails after leaving here

Thanks Imar
 
Old July 31st, 2009, 03:57 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 there,

AFAIK, you can'ty do this programmatically using an API. However, you can loop through the App_Themes folder and get the names from there:
Code:
string rootPath = Server.MapPath("~/App_Themes");
var themesFolders = System.IO.Directory.GetDirectories(rootPath);
foreach (string themeFolder in themesFolders)
{
  string theme = new System.IO.DirectoryInfo(themeFolder).Name;
  Label1.Text += string.Format("{0}<br />", 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 July 31st, 2009, 05:17 PM
Authorized User
 
Join Date: Jul 2009
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Perfect! Thank you. You should see my sln it's a mess.

I wish the Forum for the book was organized by chapter, It would help me find things quicker as well as reduce the same questions you probably get over and over. I notice many people start the the thread with the chapter I'll do that from now on.

Thanks again
 
Old August 1st, 2009, 02:58 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
I notice many people start the the thread with the chapter I'll do that from now on.
Excellent idea, especially if you include the page number as well. That makes it easy for everyone to find relevant topics and easy for me to see what the question is about exactly.

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!





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to declare the global variable in global.asax? calyn_gately ASP.NET 3.5 Basics 0 August 6th, 2008 08:06 PM
Exception of get theme JasonF430 ASP.NET 2.0 Basics 0 April 16th, 2008 01:31 AM
Theme Selector wont pick up other theme Tawanda BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 5 May 4th, 2007 08:44 AM
theme selector rav BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 February 12th, 2007 12:44 AM
page theme zhugeliang ASP.NET 2.0 Basics 1 January 9th, 2007 02:40 AM





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