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 November 3rd, 2010, 11:43 AM
Authorized User
 
Join Date: Feb 2010
Posts: 42
Thanks: 9
Thanked 0 Times in 0 Posts
Default Chapter 8 - Using Treeview

I have an error in my MasterPage that I can't figure out. I'm sure I've done something wrong because this book is fantastic!

The error: Error 1 c:\BegASPNET\Site\MasterPages\Frontend.master.vb(2 7): error BC30311: Value of type 'Boolean' cannot be converted to 'System.Web.UI.WebControls.TreeView'.


Code:
Partial Class MasterPages_Frontend
  Inherits System.Web.UI.MasterPage

  Protected Sub ThemeList_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ThemeList.SelectedIndexChanged
    Dim preferredTheme As HttpCookie = New HttpCookie("PreferredTheme")
    preferredTheme.Expires = DateTime.Now.AddMonths(3)
    preferredTheme.Value = ThemeList.SelectedValue
    Response.Cookies.Add(preferredTheme)
    Response.Redirect(Request.Url.ToString())
  End Sub

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Not Page.IsPostBack Then
      Dim selectedTheme As String = Page.Theme
      Dim preferredTheme As HttpCookie = Request.Cookies.Get("PreferredTheme")
      If preferredTheme IsNot Nothing Then
        selectedTheme = preferredTheme.Value
      End If
      If Not String.IsNullOrEmpty(selectedTheme) AndAlso ThemeList.Items.FindByValue(selectedTheme) IsNot Nothing Then
        ThemeList.Items.FindByValue(selectedTheme).Selected = True
      End If
        End If
        Select Case Page.Theme.ToLower()
            Case "darkgrey"
                Menu1.Visible = False
                TreeView1 = True
            Case Else
                Menu1.Visible = True
                TreeView1 = False
        End Select
        
  End Sub

End Class
 
Old November 3rd, 2010, 12:00 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
I'm sure I've done something wrong because this book is fantastic!
That's good to hear!

Take a look at this code:

Code:
 
Case "darkgrey"
  Menu1.Visible = False
  TreeView1 = True
Case Else
  Menu1.Visible = True
  TreeView1 = False
You're trying to assign True or False to the entire TreeView. Instead you need to assign it to its Visible property:

Code:
 
Case "darkgrey"
  Menu1.Visible = False
  TreeView1.Visible = True
Case Else
  Menu1.Visible = True
  TreeView1.Visible = False
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!
 
Old November 3rd, 2010, 01:55 PM
Authorized User
 
Join Date: Feb 2010
Posts: 42
Thanks: 9
Thanked 0 Times in 0 Posts
Default Thanks!!!!

Tahnks a million!

As it turned out, I had copied your source file. However, it created a new directory and, in fact, never overlayed my file with the error. All along I thought I was looking at your source code! Live and learn!

Thanks, again.

Ps. I'm sending you a new problem. Seems I do little except read your book and do the exercises. It is a lot of fun!





Similar Threads
Thread Thread Starter Forum Replies Last Post
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
treeview mahmutmol ASP.NET 2.0 Professional 0 August 21st, 2006 06:46 AM





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