asp.net mvc dropdownlist best practice

R

rodchar

Hi All,

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

Thanks,
rodchar
 
G

Gregory A. Beamer

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,
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top