views:

259

answers:

2

Can anyone please tell what's the exact differences between partial views and user controls in an MVC app? Which one is feasible to use? I am using user controls for filling my views which have one or more tabs(which i have added using Ajax control toolkit). I want to know about advantages/disadvantages while using partial views and user controls.

Thanks, Kaps

+6  A: 

Partial Views and User Controls are basically the same thing. User Controls are just a way of distinguishing between regular Views and Partials. When you see the "Partial.ascx", it's immediately obvious that it's a Partial because the icon is different in Visual Studio.

There's nothing stopping you from using a regular *.aspx file as a Partial. In fact, some people do exactly this, and prefix their aspx Partial names with an underscore (ex: _UserStatus.aspx).

My personal preference is to use the ascx files instead because it's easier to tell that something is a partial at a glance.

Ryan Rivest
+3  A: 

I mostly agree with Ryan. However one point to consider though is that user controls have an implementation of events whereas partial views do not.

Kindness,

Dan

Daniel Elliott
What you said is one of the most important difference between them. Thanks for reminding that also.
Braveyard