Wrox Programmer Forums
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 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 May 19th, 2008, 04:20 AM
Registered User
Join Date: May 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help with code from book

Please help my find error in code.

Create file in App_Code: Helpers.cs

using System.Web;
using System.IO;
using System.Web.Caching;

namespace MB.TheBeerHouse
    public static class Helpers
        public static string[] GetThemes()
            if (HttpContext.Current.Cache["SiteThemes"] != null)
                return (string[])HttpContext.Current.Cache["SiteThemes"];
                string themesDirPath = HttpContext.Current.Server.MapPath("~/App_Themes");
                string[] themes = Directory.GetDirectories(themesDirPath);
                for (int i = 0; i <= themes.Length - 1; i++)
                    themes[i] = Path.GetFileName(themes[i]);
                CacheDependency dep = new CacheDependency(themesDirPath);
                HttpContext.Current.Cache.Insert("SiteThemes", themes, dep);
                return themes;
try use GetTheme() method in ThemeSelector.ascx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MB.TheBeerHouse;

public partial class ThemeSelector : System.Web.UI.UserControl
    protected void Page_Load(object sender, EventArgs e)
        ddlThemes.DataSource = Helpers.GetTheme();
but get error.

Please help my fixed this error.

Old May 19th, 2008, 05:04 AM
Friend of Wrox
Join Date: Mar 2007
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts

boro - it's all in a name :D. in your definition, you have:

ddlThemes.DataSource = Helpers.GetTheme();

try using:

ddlThemes.DataSource = Helpers.GetThemes();

as this is how you've defined the method in the helpers.cs class. hope this works.


Old March 12th, 2009, 11:28 PM
Registered User
Join Date: Mar 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default App_code namespace error

This solution may come a little too late for “boro” but some other people may find it useful. In VS 2005, App_Code is a directory with funny characteristics. I found the solution in https://forums.asp.net/ (suggested by bpeterson) and I searched for “App_code namespace error”. Of course, one must spell all the names correctly (uppercase/ lowercase in C#) and the rest. Moreover, in VS 2005, when you create a class file in App_Code directory, by default, its “Build Action” property is marked as “Content”. You must click on the filename (in this case Helpers.cs) then in the properties window (usually located below the solution explorer window), find “Build Action” property which itself is grouped under “Advanced”. Next set the “Build Action” property to “Compile”. In my case, I had to copy the file to another file. Delete the offending file. Recreated it in App_Code directory. Then set its “Build Action” property to “compile”. I hope this is helpful.


Similar Threads
Thread Thread Starter Forum Replies Last Post
C# Code for this book now available jminatel BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 April 10th, 2006 09:16 AM
Where is the code of this book! zjut C# 0 October 18th, 2004 10:08 PM
How can i get the code of this book? jervis Wrox Book Feedback 3 November 26th, 2003 03:17 AM
Where can you get the code for the book jjk8501 Classic ASP Databases 1 September 18th, 2003 07:07 AM

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