Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional 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 Display Modes
  #1 (permalink)  
Old June 7th, 2006, 10:41 AM
Authorized User
 
Join Date: May 2006
Location: fayetteville, Arkansas, USA.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to notrosh
Default Changing Themes

I am trying to let the user select themes. I have all the code in place but I am getting no results. Can anyone take a look and let me know what is wrong

thanks in advance

Reply With Quote
  #2 (permalink)  
Old June 7th, 2006, 10:45 AM
Imar's Avatar
Wrox Author
Points: 66,632, Level: 100
Points: 66,632, Level: 100 Points: 66,632, Level: 100 Points: 66,632, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,124
Thanks: 65
Thanked 1,386 Times in 1,366 Posts
Default

Sure, if you post the code....

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #3 (permalink)  
Old June 7th, 2006, 11:40 AM
Authorized User
 
Join Date: May 2006
Location: fayetteville, Arkansas, USA.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to notrosh
Default

Here is all the code I used. If someone has a better way please let me know.

Classes

---------BasePage Class------------
namespace MB.NWA.UI
{
    public class BasePage : System.Web.UI.Page
    {
        protected override void OnPreInit(EventArgs e)
        {
            string id = Globals.ThemesSelectorID;
            if (id.Length > 0)
            {
                if (this.Request.Form["_EVENTTARGET"] == id && !string.IsNullOrEmpty(this.Request.Form[id]))
                {
                    this.Theme = this.Request.Form[id];
                    this.Session["CurrentTheme"] = this.Theme;
                }
                else
                {
                    if (this.Session["CurrentTheme"] != null)
                        this.Theme = this.Session["CurrentTheme"].ToString();

                }
            }
            base.OnPreInit(e);
        }
    }
}

---------Globals Class---------

namespace MB.NWA
{
    public static class Globals
        {
             public static string ThemesSelectorID = "";
        }
----------Helpers Class----------

namespace MB.NWA.UI
{
    public static class Helpers
    {
        public static string[] GetThemes()
        {
            if (HttpContext.Current.Cache["SiteThemes"] != null)
            {
                return (string[])HttpContext.Current.Cache["SiteThemes"];
            }
            else
            {
                string themesDirPath = HttpContext.Current.Server.MapPath("~/App_Themes");
                string[] themes = Directory.GetDirectories(themesDirPath);
                for (int i = 0; i<= themes.Length - 1; i++)
                    themes[i] = Path.GetFileName(themes[i]);
                CacheDependency dep = new CacheDependency(themesDirPath);
                HttpContext.Current.Cache.Insert("SiteThemes", themes, dep);
                return themes;
            }
        }
    }
}

----------User Control----------


namespace MB.NWA.UI.Controls
{
    public partial class Controls_ThemeSelector : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {


            if (Globals.ThemesSelectorID.Length == 0)
                Globals.ThemesSelectorID = ddlThemes.UniqueID;

            ddlThemes.DataSource = Helpers.GetThemes();
            ddlThemes.DataBind();

            ddlThemes.SelectedValue = this.Page.Theme;
        }
    }
}

}


----------Default.aspx----------
public partial class _Default : MB.NWA.UI.BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}

that is really just about all I have done. The themes show up in the dropdown box. However when i change them nothing happens. I have no compliation, syntax, or run-time errors. I also have the theme dropdown box property Autopostback = "true", any help would be greatly appreciated.

Thanks in advance

Reply With Quote
  #4 (permalink)  
Old June 7th, 2006, 12:19 PM
Authorized User
 
Join Date: May 2006
Location: fayetteville, Arkansas, USA.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to notrosh
Default

Hi Everyone thanks for the help.

However I figured out the problem

thanks,

zdavis

Reply With Quote
  #5 (permalink)  
Old June 7th, 2006, 12:25 PM
Imar's Avatar
Wrox Author
Points: 66,632, Level: 100
Points: 66,632, Level: 100 Points: 66,632, Level: 100 Points: 66,632, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,124
Thanks: 65
Thanked 1,386 Times in 1,366 Posts
Default

Would you mind sharing how you fixed it? I am sure some future visitor will benefit from your answer....

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Reply With Quote
Reply


Thread Tools
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
Scrollbar in Themes. 99mary BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 March 28th, 2007 07:54 PM
Use Themes? the.pi.man ASP.NET 2.0 Basics 2 March 7th, 2007 07:44 AM
Themes bmains ASP.NET 2.0 Basics 2 August 2nd, 2004 08:48 AM



All times are GMT -4. The time now is 03:38 PM.


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