Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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 January 31st, 2011, 01:19 AM
Registered User
Join Date: Jan 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question Chapter 7 - Treeview Code

It struck me that the Page_Load code on page 259 to hide/show the treeview/menu depending on which theme you were using was not an ideal way to apply themes as you would have to make a code change with each new theme.

If you create a skin for the treeview and one for the menu in each of the themes, you can set the "visible" to true/false there instead to get the same result while keeping theme code in the themes themselves. In Monochrome, for example:

<asp:Menu runat="server" SkinID="navMenu" Visible="true"></asp:Menu>
<asp:TreeView runat="server" SkinID="navTree" Visible="false"></asp:TreeView>
(you would want to add the SkinID to the respective controls as well for this to work)

Would this not be the preferred way to do this?
Reply With Quote
  #2 (permalink)  
Old January 31st, 2011, 03:29 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts

Hi there,

You are absolutely right. This is a very clean way to do it, without the need to maintain code when you change or add themes.

In the book I wanted to show how to programmatically change page layout / behavior based on the theme. That's why I chose this route. However, if all you need to do is hide or show the relevant [FONT='Calibri','sans-serif']navigation [/FONT]controls, your solution is preferred.

The only "downside" I see with this is that themes now need to know about each other. In other words, Monochrome needs to know it needs to hide a navTree TreeView. Not a real big problem though, as themes often end up being tied to a specific application anyway.


Imar Spaanjaars
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!
Reply With Quote

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
Chapter 8 - Using Treeview demac3 BOOK: Beginning ASP.NET 4 : in C# and VB 2 November 3rd, 2010 01:55 PM
Chapter 6 - Code Download Missing for this Chapter dbaechtel BOOK: Professional SharePoint 2007 Development ISBN: 978-0-470-11756-9 0 August 11th, 2009 11:02 AM
Chapter 7 re hiding root element in TreeView control stephjnca BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 May 27th, 2009 02:26 PM
Chapter 10 Treeview Control adonnaru BOOK: Access 2003 VBA Programmer's Reference 1 September 19th, 2006 01:04 PM
Chapter 10: TreeView example postoak7 BOOK: Access 2003 VBA Programmer's Reference 0 September 19th, 2006 12:25 PM

All times are GMT -4. The time now is 12:21 PM.

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