asp.net mvc dropdownlist best practice

Discussion in 'ASP .Net' started by rodchar, Sep 30, 2009.

  1. rodchar

    rodchar Guest

    Hi All,

    Where's the best place to load up my dropdownlist? in the Model, View or
    Controller?

    Thanks,
    rodchar
    rodchar, Sep 30, 2009
    #1
    1. Advertising

  2. =?Utf-8?B?cm9kY2hhcg==?= <> wrote in
    news::

    > Hi All,
    >
    > Where's the best place to load up my dropdownlist? in the Model, View
    > or Controller?


    Let's think this one through, using a bit of theory to get us going.

    I am going to oversimplify this on purpose to illustrate (so please
    don't correct me with technical bs):

    In MVC, the model represents state. If you need to grasp its purpose,
    think of it as a data construct. The view is an I/O construct where the
    model is presented to user (the "viewer") so he can interact with it.The
    controller contains behavior and is the piece that sends the proper
    model to the view so it can be "viewed".

    So here are the questions:

    1. Is loading the DropDownList working with state?
    2. Is loading the DropDownList required for the user to view the state?
    3. Is loading the DropDownList application behavior?

    Of these, if thought through, only one of the questions should yield a
    yes answer.

    The DropDownList, itself, is not state. Loading it is not application
    behavior either. So this leaves only one place to logically load a
    DropDownList.

    The answer for binding UI elements is the View. The controller will make
    the call to get the right model, but it does not bind it. And the model
    should not be responsible for UI behavior.

    Peace and Grace,


    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA

    Twitter: @gbworld
    Blog: http://gregorybeamer.spaces.live.com

    *******************************************
    | Think outside the box! |
    *******************************************
    Gregory A. Beamer, Sep 30, 2009
    #2
    1. Advertising

  3. rodchar

    rodchar Guest

    I appreciate the detailed reply.
    Thank you for the insight,
    rod.

    "Gregory A. Beamer" wrote:

    > =?Utf-8?B?cm9kY2hhcg==?= <> wrote in
    > news::
    >
    > > Hi All,
    > >
    > > Where's the best place to load up my dropdownlist? in the Model, View
    > > or Controller?

    >
    > Let's think this one through, using a bit of theory to get us going.
    >
    > I am going to oversimplify this on purpose to illustrate (so please
    > don't correct me with technical bs):
    >
    > In MVC, the model represents state. If you need to grasp its purpose,
    > think of it as a data construct. The view is an I/O construct where the
    > model is presented to user (the "viewer") so he can interact with it.The
    > controller contains behavior and is the piece that sends the proper
    > model to the view so it can be "viewed".
    >
    > So here are the questions:
    >
    > 1. Is loading the DropDownList working with state?
    > 2. Is loading the DropDownList required for the user to view the state?
    > 3. Is loading the DropDownList application behavior?
    >
    > Of these, if thought through, only one of the questions should yield a
    > yes answer.
    >
    > The DropDownList, itself, is not state. Loading it is not application
    > behavior either. So this leaves only one place to logically load a
    > DropDownList.
    >
    > The answer for binding UI elements is the View. The controller will make
    > the call to get the right model, but it does not bind it. And the model
    > should not be responsible for UI behavior.
    >
    > Peace and Grace,
    >
    >
    > --
    > Gregory A. Beamer
    > MVP; MCP: +I, SE, SD, DBA
    >
    > Twitter: @gbworld
    > Blog: http://gregorybeamer.spaces.live.com
    >
    > *******************************************
    > | Think outside the box! |
    > *******************************************
    >
    rodchar, Oct 2, 2009
    #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. rmn190
    Replies:
    2
    Views:
    2,333
    Arne Vajhøj
    Jan 10, 2008
  2. shapper
    Replies:
    2
    Views:
    20,719
    Altaf
    Aug 22, 2009
  3. Paulo
    Replies:
    3
    Views:
    463
    Peter Bromberg [C# MVP]
    Dec 4, 2008
  4. Crazy Cat
    Replies:
    1
    Views:
    672
    schepp
    Sep 3, 2009
  5. rodchar

    mvc best practice

    rodchar, Oct 6, 2009, in forum: ASP .Net
    Replies:
    0
    Views:
    342
    rodchar
    Oct 6, 2009
Loading...

Share This Page