asp.net mvc dropdownlist best practice

  • Thread starter Thread starter rodchar
  • Start date Start date
R

rodchar

Hi All,

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

Thanks,
rodchar
 
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! |
*******************************************
 
Back
Top