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 March 26th, 2009, 03:40 PM
Authorized User
 
Join Date: Mar 2009
Posts: 20
Thanks: 7
Thanked 0 Times in 0 Posts
Default question about App_Code/ConfigSection.cs

Hi all,

Can anybody please tell me in brief what is going on in "App_Code/ConfigSection.cs"?
why are we calling base[] in every get method? what does it return? Thank you!
Code:
[ConfigurationProperty("defaultCacheDuration", DefaultValue = "600")]
publicint DefaultCacheDuration
{
get { return (int)base["defaultCacheDuration"]; }
set { base["defaultCacheDuration"] = value; }
}
[ConfigurationProperty("contactForm", IsRequired=true)]
publicContactFormElement ContactForm
{
get { return (ContactFormElement) base["contactForm"]; }
}
 
Old March 26th, 2009, 06:58 PM
Friend of Wrox
Points: 546, Level: 8
Points: 546, Level: 8 Points: 546, Level: 8 Points: 546, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2009
Posts: 105
Thanks: 3
Thanked 20 Times in 19 Posts
Default

In brief the configSection.cs is used to read the name value pairs in the Web.config file. If you collapse the code down to the individual classes in configSetion.cs you will see the first class is TheBeerHouseSection, which matches a section in the webconfig. In the TheBeerHouse section of the web.config are several elements, which have matching *Element classes in the configSection.cs; and each *Element class has read only properties in TheBeerHouseSection class.

If you want to create your own module, say a module for resources/links, you would need to add a corresponding class to the configSection.cs, add a read only property to the *Section class and an element to the Web.confg.

As for the base, it is refering to the base class (either ConfigurationSection or ConfigurationElement)

Hopefully that helps you.


Steve
The Following User Says Thank You to Steve S For This Useful Post:
Jyothi_23 (March 27th, 2009)
 
Old March 27th, 2009, 11:08 AM
Authorized User
 
Join Date: Mar 2009
Posts: 20
Thanks: 7
Thanked 0 Times in 0 Posts
Thumbs up

hello Steve,

Thanks very much . Now I understood very clearly and it is a nice explanation from you.





Similar Threads
Thread Thread Starter Forum Replies Last Post
ConfigSection Muhammad Zeeshan BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 January 21st, 2008 02:29 PM
in web.config or ConfigSection.cs? jini BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 February 3rd, 2007 04:39 AM
ConfigSection Error - CS0029: Cannot implicitly co bigluzer BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 4 January 9th, 2007 12:37 AM
configSection.cs and other bafflements MM BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 November 16th, 2006 06:45 PM
Renaming App_Code jacob .NET Web Services 5 July 4th, 2006 12:20 AM





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