Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 1.1
This is the forum to discuss the Wrox book Beginning ASP.NET 1.1 with Visual C#.NET 2003 by Chris Ullman, John Kauffman, Chris Hart, Dave Sussman, Daniel Maharry; ISBN: 9780764557088
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 1.1 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 21st, 2004, 09:32 PM
Registered User
 
Join Date: May 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to nickcoleman
Default Using Web.Config with BehindCode Classes

I'm just finishing up Chapter 12 of the Begining ASP.Net 1.1 with VB 2003. The chapter has us take the code out of default.aspx file and put it in a default.aspx.vb class file.

Not a problem except that my ConfigurationSetting

  Dim connectionString As String = ConfigurationSettings.AppSettings("ConnectionStrin g")

to the database via the web.config file no longer works. (The actual database connection string is defined in the web.config file.)

I get an error message that ConfigurationSettings is not defined. All worked great until I moved the functions to the .vb file.

Question: How can I continue to use the web.config file application settings when moving the code to a class file. (Authors don't cover it in the book.)

Cheers,

Nick
 
Old May 22nd, 2004, 08:14 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

You did include the System.Configuration namespace correct? In addition, you can also do this to retrieve a value from the configuration settings:

Dim objKey as System.Collections.Specialized.NameValueCollection = System.Configuration.ConfigurationSettings.AppSett ings
Dim connectionString As String = objKey.Get("ConnectionString")

Brian
 
Old May 22nd, 2004, 11:56 AM
Registered User
 
Join Date: May 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to nickcoleman
Default

Thanks ... I needed to Import the System.Configuration Namespace.

Works great now -- guess I need to get a reference document that gives an overview of which Namespaces are required for which situation.


Cheers,

Nick





Similar Threads
Thread Thread Starter Forum Replies Last Post
web.config vs. app.config darlo Visual Studio 2005 11 August 20th, 2008 07:23 AM
Web Config SteveP55419 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 January 3rd, 2007 04:19 PM
Web Config C# akshay144 VS.NET 2002/2003 0 November 10th, 2006 10:21 AM
Custom classes in Web Services rodmcleay C# 13 November 2nd, 2006 07:30 PM
Web.Config tranzformerz ASP.NET 1.0 and 1.1 Basics 1 August 29th, 2005 05:59 PM





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