views:

98

answers:

3

I'm writing a custom control and I would like to include some configuration options for the control, but I'm not sure where I should put them.

I could probably put them in the the web.config of the application where I'm using the control, but that seems a bit messy to me.

What should I be doing?

EDIT: The configuration data will typically deal be pretty simple things, like file path information etc. They won't be things that the end user changes, rather they are things that the developer would set up at design time.

+1  A: 

What about using just a regular .xml file in the control's class or in the app where you are using it?

I understand what you mean when you say that you don't want to put it in your web.config file. We have an app that has a lot of configuration options in the web.config and it is becoming difficult to manage.

Jeremy Cron
That's probably what I'll end up doing :D Thx.
DrG
+1  A: 

What are some examples of the configuration options for the control?

If you want the end users to be able to change them, you could expose properties within the User Control that you can bind to in the .aspx file (or code behind). The properties could also have default values. If your config options are very complex, then this option would probably not work for you, but if they are simple types, it may.

-

see also (Bindable attribute)

http://msdn.microsoft.com/en-us/library/system.componentmodel.bindableattribute.aspx

Aaron Hoffman
A: 

Are these configuration options for every instance of the control? If so, then they belong in the web.config, which is where all configuration should go. Use custom configuration sections so that they can be strongly-typed and validated.

If these options differ from one instance of the control to another, then, as said by Aaron Hoffman, they should be bindable properties, and let the caller decide what to do with them.

John Saunders