Wrox Programmer Forums
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 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 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?
Old January 31st, 2011, 03:29 AM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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!

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

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