Custom controls settings, best practice question

Discussion in 'ASP .Net' started by Laurent Bugnion, Aug 26, 2006.

  1. 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
     
    Laurent Bugnion, Aug 26, 2006
    #1
    1. Advertising

  2. Laurent Bugnion

    sloan Guest

    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" <> wrote in message
    news:...
    > 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
     
    sloan, Aug 26, 2006
    #2
    1. Advertising

  3. 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
     
    Laurent Bugnion, Aug 26, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Siegfried Heintze
    Replies:
    0
    Views:
    2,326
    Siegfried Heintze
    Oct 24, 2005
  2. donet programmer
    Replies:
    3
    Views:
    1,621
    Gregory A. Beamer
    Nov 20, 2009
  3. Hannes Schmiderer

    Best Practice with Custom Controls and Event Model

    Hannes Schmiderer, Oct 9, 2003, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    221
    Hannes Schmiderer
    Oct 9, 2003
  4. Oyvind Pettersen
    Replies:
    4
    Views:
    97
    Michael Fellinger
    Apr 9, 2010
  5. oldyork90
    Replies:
    1
    Views:
    175
    Jeremy J Starcher
    Sep 10, 2008
Loading...

Share This Page