By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,853 Members | 2,246 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,853 IT Pros & Developers. It's quick & easy.

Custom controls settings, best practice question

P: n/a
Hi,

I like to develop custom controls for a number of webpages. These
controls are often customizable, so that they can be reused in a number
of situations.

My question is: What is the best practice for configuring a custom
control. As far as I can say, I have the following alternatives:

- Defining properties for the control, and setting these in the ASPX
page where the control is included (this is what I do now). This has the
advantage that the settings are defined in the same file as the control
itelf, only one file to manage. However, when there are many settings,
one might lose the overview. Also, these properties are parsed on every
roundtrip, so it's not really efficient.

- Using a settings section in web.config. This has the advantage that
settings are not parsed on every roundtrip.

- A mix of these two solutions.

What are your thoughts?

Greetings,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Aug 26 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a

If the setting are "set 1 time" for the majority of cases..
then I'd go with a custom configuration section/custom handler.

If the property(ies) are going to change for each page that has an
instance(s) of your control, use a property, and set it on the page_load.

If your "set 1 time" is the case most of the time, then use the custom
config section, but add a property so a specific page (using your control)
can override the default setting.

.....

Once you get used to (and getting past your first one) .. to using custom
config sections... you'll end up liking them I think.

spaces.msn.com/sholliday/

check my smtp configuration tool, I have a custom config section/handler
written there.

make sure you put a break point on the handler itself (.Create method?) so
you can see it parsing the xml to create the concrete objects.

...

"Laurent Bugnion" <ga*********@bluewin.chwrote in message
news:O1**************@TK2MSFTNGP03.phx.gbl...
Hi,

I like to develop custom controls for a number of webpages. These
controls are often customizable, so that they can be reused in a number
of situations.

My question is: What is the best practice for configuring a custom
control. As far as I can say, I have the following alternatives:

- Defining properties for the control, and setting these in the ASPX
page where the control is included (this is what I do now). This has the
advantage that the settings are defined in the same file as the control
itelf, only one file to manage. However, when there are many settings,
one might lose the overview. Also, these properties are parsed on every
roundtrip, so it's not really efficient.

- Using a settings section in web.config. This has the advantage that
settings are not parsed on every roundtrip.

- A mix of these two solutions.

What are your thoughts?

Greetings,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch

Aug 26 '06 #2

P: n/a
Hi,

sloan wrote:
If the setting are "set 1 time" for the majority of cases..
then I'd go with a custom configuration section/custom handler.
Yes.

If the property(ies) are going to change for each page that has an
instance(s) of your control, use a property, and set it on the page_load.
That's what I currently do.

If your "set 1 time" is the case most of the time, then use the custom
config section, but add a property so a specific page (using your control)
can override the default setting.
I will have properties anyway, because of the flexibility they offer.
Once you get used to (and getting past your first one) .. to using custom
config sections... you'll end up liking them I think.
I know how to do config sections, I use them already for other purposes
(Page). My question was related to custom controls specifically. What I
like in my current solution is that the custom control's definition is
in one place only, and that's the ASPX page, but I am not against your
suggestions at all.

Thanks for your input!

Greetings,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Aug 26 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.