PC Review


Reply
Thread Tools Rate Thread

asp.net mvc dropdownlist best practice

 
 
rodchar
Guest
Posts: n/a
 
      30th Sep 2009
Hi All,

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

Thanks,
rodchar
 
Reply With Quote
 
 
 
 
Gregory A. Beamer
Guest
Posts: n/a
 
      30th Sep 2009
=?Utf-8?B?cm9kY2hhcg==?= <(E-Mail Removed)> wrote in
news:6055B854-1E5E-45ED-8F6C-(E-Mail Removed):

> 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! |
*******************************************
 
Reply With Quote
 
rodchar
Guest
Posts: n/a
 
      2nd Oct 2009
I appreciate the detailed reply.
Thank you for the insight,
rod.

"Gregory A. Beamer" wrote:

> =?Utf-8?B?cm9kY2hhcg==?= <(E-Mail Removed)> wrote in
> news:6055B854-1E5E-45ED-8F6C-(E-Mail Removed):
>
> > 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! |
> *******************************************
>

 
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
What is the best practice for DropDownList with static items? bogdan Microsoft ASP .NET 1 7th Apr 2008 05:44 PM
When I set the DropDownList.SelectedIndex of ONE DropDownList they ALL change! S_K Microsoft ASP .NET 5 14th Nov 2007 04:51 PM
DropDownList inside GridView: How to set SelectedIndex for the DropDownList? keithb Microsoft ASP .NET 0 1st May 2006 11:54 PM
GridView: Filter DropDownList for another DropDownList =?Utf-8?B?SnVhbmpv?= Microsoft ASP .NET 0 29th Dec 2005 07:44 AM
GridView: Filtr DropDownList from another DropDownList =?Utf-8?B?SnVhbmpv?= Microsoft ASP .NET 0 23rd Dec 2005 01:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:35 AM.