Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 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 June 10th, 2007, 07:10 PM
Registered User
 
Join Date: Oct 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 2 ThemeSelector - Puzzled

I wrote the top code for the themeselector in the basepage and the themeselector did not work, however i copied the code from the chapter2 download and replaced the code completely and the themeselector worked. my question is that for the life of me I have no idea of any difference between the code. it is the same fricken thing except mine does not work and the one i copied does. my code is the top code and the code i copied is beneath it. any ideas would be appreciated thanks.


using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace MB.TheBeerHouse.UI
{
    public class BasePage : System.Web.UI.Page
    {
        protected override void OnPreInit(EventArgs e)
        {
            string id = Globals.ThemesSelectorID;



            if (id.Length > 0)
            {
                // if this is a postback caused by the theme selector's dropdownlist,
                // retrieve the selected theme and use it for the current page request
                // && !string.IsNullOrEmpty(this.Request.Form[id])
                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 not a postback, or it is a postback cause by a control other than
                    // the theme selector, set the page's theme with the value that is in the
                    // session variable, if that variable is present

                    if (this.Session["CurrentTheme"] != null)
                        this.Theme = this.Session["CurrentTheme"].ToString();

                        //this.Theme = "PlainHtmlYellow";
                }
            }



            base.OnPreInit(e);
        }
    }
}



my code on top the copied code is below

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace MB.TheBeerHouse.UI
{
    public class BasePage : System.Web.UI.Page
    {
        protected override void OnPreInit(EventArgs e)
        {
            string id = Globals.ThemesSelectorID;
            if (id.Length > 0)
            {
                // if this is a postback caused by the theme selectors dropdownlist,
                // retrieve the selected theme and unse it for the current page request
                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);
        }
    }
}


 
Old June 11th, 2007, 12:12 AM
Authorized User
 
Join Date: May 2006
Posts: 99
Thanks: 0
Thanked 1 Time in 1 Post
Default

The problem is the form request name. It is double underscore __EVENTTARGET not single underscore _EVENTTARGET.

 
Old June 11th, 2007, 07:43 AM
Registered User
 
Join Date: Oct 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

wow thanks i am not sure i would have caught that!






Similar Threads
Thread Thread Starter Forum Replies Last Post
ThemeSelector class error xrica32 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 4 August 14th, 2007 08:20 PM
Generics chapter 12 difficult chapter i found ...? Larryz C# 2005 1 July 4th, 2007 09:40 PM
puzzled with tomcat5.5.9 Edward King Apache Tomcat 1 September 21st, 2005 02:00 AM





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