Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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;
              }
        }
    }
}
 


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
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



All times are GMT -4. The time now is 06:20 PM.


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