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 March 7th, 2009, 06:26 PM
Authorized User
 
Join Date: Mar 2009
Posts: 11
Thanks: 5
Thanked 0 Times in 0 Posts
Red face 2 Clicks to Update Theme Selector

I have changed my base page OnPreInit to get the theme name, not the full control name from Globals.ThemesSelectorID since an ImageButton does not store Request.Form[id] like a drop down list. I found that Request.Form[id] stores the value what was selected in the drop down... is this correct?

Since Request.Form[id] is not available, I pass Globals.ThemesSelectorID = myControl.ID. This gives me the correct theme name that was clicked.

The problem is that I have to click an imagebutton twice before the theme changes. On the first click, a test label next to my imageButton updates to display the new theme name that was clicked. However, it is not until the next click that the theme actually gets updated!

Is there somthing different about setting this.theme = Request.Form[id] from myControl.ID (themeName)?

Why does the book code pass uniqueID to Globals.ThemesSelectorID, not ID? If I pass uniqueID the value looks like ctl00$ThemeSelector1$goldLabel instead of the theme name of goldLabel. I am guessing Request.Form[id] provides the theme name only where Globals.ThemesSelectorID provides the full control information like above.

Why woulld only passing the ID (theme name) and not using the full control name cause the page to take 2 clicks to change the theme?

Code:
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 RC.RPC_Group.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 (Page.IsPostBack)
                {
                    this.Theme = id;
                    this.Session["CurrentTheme"] = this.Theme;
                }
                else
                {
                    if (this.Session["CurrentTheme"] != null)
                        this.Theme = this.Session["CurrentTheme"].ToString();
                }
                base.OnPreInit(e);
            }
        }
    }
}
Code:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using RC.RPC_Group;
namespace RC.RPC_Group.UI.Controls
{
    public partial class ThemeSelector : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
              WebControl myControl = sender as WebControl;
              if (myControl != null)
              {
                  Label1.Text = myControl.ID;
                  Globals.ThemesSelectorID = myControl.ID;
              }
        }
    }
}





Similar Threads
Thread Thread Starter Forum Replies Last Post
theme selector from profile Maxxim BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 July 1st, 2007 10:35 PM
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
theme selector inputcontrol highlight issue michaelitrn BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 September 10th, 2006 02:58 PM
Table selector/ insert-update-delete pages karib PHP Databases 1 September 8th, 2006 12:50 PM





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