PC Review


Reply
Thread Tools Rate Thread

Custom controls settings, best practice question

 
 
Laurent Bugnion
Guest
Posts: n/a
 
      26th Aug 2006
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
 
Reply With Quote
 
 
 
 
sloan
Guest
Posts: n/a
 
      26th Aug 2006

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" <galasoft-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
Laurent Bugnion
Guest
Posts: n/a
 
      26th Aug 2006
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WPF question - ControlDesigner for WPF custom controls? =?Utf-8?B?RG9yb24=?= Microsoft C# .NET 1 10th Apr 2007 08:10 PM
question about custom controls =?Utf-8?B?cm9kY2hhcg==?= Microsoft VB .NET 4 7th Dec 2004 08:57 PM
Question on building Web Custom Controls The Alchemist Microsoft ASP .NET 1 2nd Jun 2004 02:35 AM
Question on building Web Custom Controls The Alchemist Microsoft VB .NET 1 2nd Jun 2004 02:35 AM
question with the web custom controls =?Utf-8?B?V29uZyBjaGlhbg==?= Microsoft ASP .NET 0 22nd Jan 2004 01:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:56 AM.