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 September 10th, 2006, 02:58 PM
Registered User
 
Join Date: Sep 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default theme selector inputcontrol highlight issue

I'm seeing a rather bizarre behavior when implementing the theme selector control and the setinputcontrolshightlight function from chapter 2. When the page loads and I click on the theme selector dropdownlist, it is automatically posted back (before allowing me to select a value). However, if I tab into the dropdown list, it work fine (including the highlighting) and posts back after I select the value. Has anybody seen this issue? Any ideas of how I can correct it?

Here is my code:
______________________________________________
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="ThemeSelector.ascx.vb" Inherits="menichols.UI.Controls.ThemeSelector" %>
<b><asp:Label runat="server" ID="locTheme" Text="Choose Theme: "></asp:Label></b>
<asp:DropDownList runat="server" ID="ddlThemes" AutoPostBack="True" />
------------------------------------------------------------
Imports menichols
Imports menichols.UI

Namespace menichols.UI.Controls
    Partial Class ThemeSelector
        Inherits System.Web.UI.UserControl

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Globals.ThemesSelectorID.Length = 0 Then
                Globals.ThemesSelectorID = ddlThemes.UniqueID
            End If

            ddlThemes.DataSource = Helpers.GetThemes()
            ddlThemes.DataBind()
            ddlThemes.SelectedValue = Me.Page.Theme

        End Sub
    End Class
End Namespace

---------------------------------------------------------
BasePage
---------------------------------------------------------
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
            Helpers.SetInputControlsHighlight(Me, "highlight", False)
            MyBase.OnLoad(e)

        End Sub

Protected Overrides Sub OnPreInit(ByVal e As System.EventArgs)
            Dim id As String = Globals.ThemesSelectorID

            If id.Length > 0 Then
                Dim profTheme As ProfileCommon = HttpContext.Current.Profile
                ' if this is a postback caused by the theme selector's dropdownlist,
                ' retrieve the selected theme and use it for the current page request
                If Me.Request.Form("__EVENTTARGET") = id AndAlso _
                        Not String.IsNullOrEmpty(Me.Request.Form(id)) Then
                    Me.Theme = Me.Request.Form(id)
                    profTheme.Preferences.Theme = Me.Theme
                Else
                    ' if not a postback, or a postback caused by controls other then the theme selector,
                    ' set the page's theme with the value found in the user's profile, if present
                    If Not String.IsNullOrEmpty(profTheme.Preferences.Theme) Then
                        Me.Theme = profTheme.Preferences.Theme
                    End If
                End If
            End If

            MyBase.OnPreInit(e)
        End Sub
---------------------------------------------------------------
helper.vb
---------------------------------------------------------------
 Public Shared Sub SetInputControlsHighlight(ByVal container As Control, ByVal className As String, ByVal onlyTextBoxes As Boolean)
            For Each ctl As Control In container.Controls
                If (onlyTextBoxes AndAlso TypeOf (ctl) Is TextBox) OrElse TypeOf (ctl) Is TextBox OrElse TypeOf (ctl) Is DropDownList OrElse _
                 TypeOf (ctl) Is ListBox OrElse TypeOf (ctl) Is CheckBox OrElse TypeOf (ctl) Is RadioButton OrElse _
                 TypeOf (ctl) Is RadioButtonList OrElse TypeOf (ctl) Is CheckBoxList Then
                    Dim wctl As WebControl
                    wctl = CType(ctl, WebControl)
                    wctl.Attributes.Add("onfocus", String.Format("this.className = '{0}';", className))
                    wctl.Attributes.Add("onblur", "this.className = '';")
                Else
                    If (ctl.Controls.Count > 0) Then _
                        SetInputControlsHighlight(ctl, className, onlyTextBoxes)
                End If
            Next
        End Sub







 


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
OptionButtons as workbook sheet selector frankjuel Excel VBA 8 February 27th, 2007 05:32 PM
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
Slot Selector motupally Classic ASP Basics 0 July 28th, 2003 05:03 AM



All times are GMT -4. The time now is 10:15 PM.


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