Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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 11th, 2013, 11:43 AM
Registered User
 
Join Date: Sep 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 6 Theme change code

Hi,
New to ASP.NET but not to programming.
Currently working on the Theme change drop down list on page 223 but am running into some errors.

This has been solved, I found another post with the same problem and solution.
When I try to change the ID to "1stpreferredTheme" I get the message "is not a valid name for the control" so I just leave of the "1st".
Second problem is when I code the event handler for the drop down list the code "PreferredTheme.Value = PreferredTheme.SelectedValue" gives me the error 'SelectedValue' is not a member of 'System.Web.HttpCookie'



This is the code so far.....

Partial Class MasterPage
Inherits System.Web.UI.MasterPage
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles 1stPreferredTheme.SelectedIndexChanged
Dim PreferredTheme As HttpCookie = New HttpCookie("PreferredTheme")
PreferredTheme.Expires = DateTime.Now.AddMonths(3)
PreferredTheme.Value = PreferredTheme.SelectedValue

End Sub
End Class

Michael.

Last edited by mfl722; June 11th, 2013 at 02:34 PM..
 
Old June 14th, 2013, 09:20 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

As you (seem to have) found out, the control ID can't start with a number. The control name used in the book is lstPreferredTheme with an l from list and not a 1 from first.

Then this code is incorrect:

Code:
PreferredTheme.Value = PreferredTheme.SelectedValue
You're trying to get the SelectedValue from the cookie (PreferredTheme) while you should get it from the DropDownList (lstPreferredTheme).

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Not able to change theme between monochrome & darkgrey Neeta Shah BOOK: Beginning ASP.NET 4 : in C# and VB 4 March 20th, 2013 03:24 PM
chapter 6- theme aman7 BOOK: Beginning ASP.NET 4 : in C# and VB 2 November 5th, 2012 01:48 AM
Theme won't change in new content page lustigon BOOK: Beginning ASP.NET 4 : in C# and VB 1 June 21st, 2010 10:03 PM
How i can change the theme(skin) of my form? sara_21 C# 2 April 8th, 2007 03:30 PM





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