0

Hallo, my team and I are about to start a project, and we would really like to use ASP.NET MVC, not the Web Forms. Why? Nothing special, just we want to learn it well and to measure what would be better to use in future projects.

But, our project has important request. We need ability to dynamically load user controls, that can be created and uploaded in runtime. With ASP.NET Web Forms and it's LoadControl method it's simple.

Can we do something like that with MVC?

Tnx

Misha N.
  • 3,455
  • 1
  • 28
  • 36

3 Answers3

3

Partial views are what you want.

MVC - Dynamically loading Partial Views

Community
  • 1
  • 1
Matthew Groves
  • 25,181
  • 9
  • 71
  • 121
0

partial views will do the trick.. or you might want to rethink why you are using a user control. is this a third party control? could this be rewritten?

leora
  • 188,729
  • 360
  • 878
  • 1,366
  • This user control can be developed separately using the SDK we should provide. – Misha N. Sep 02 '09 at 14:06
  • so it can interact with the system using SDK, and it need to get back some information back. With ASP.NET Web Forms UserControls would need to implement some interface. – Misha N. Sep 02 '09 at 14:22
0

You can use

<%

foreach (var thing in things)

    Html.RenderPartial("location/page.ascx",thing);

%>

from within your view

Amir Ismail
  • 3,865
  • 3
  • 20
  • 33
Jon Spokes
  • 2,599
  • 2
  • 18
  • 21