tags:

views:

55

answers:

2

I have existing ASP.NET MVC View pages and View user controls which I currently use in normal straightforward ASP.NET MVC fashion, sometimes I use RenderPartialView or RenderAction, etc. By themselves they include tag. I would like to dynamically load either Views or ViewUserControl based on the selection in a dropdown list.

I'm having trouble deciding should I remove from Views and controls and put it just into the one View that will do dynamic rendering or to leave it there and leave outside of the .

What do you think and how would you go about it?

+1  A: 

I would probably try to load the contents of a div after doing an AJAX call to get the contents. See the AJAX get call in the jQuery docs.


Or are the possibilities of what control to load so small you could just hide/show div's that are already in the page?

Mark
A: 

You can use JQuery to get the HTML from your Partial views and substitute it in the div. It could be something like this:

$.get('/Controller/Action',function(data){
   $('div').innerHtml(data); 
});

I did it this way and it works. /Controller/Action can be a partial view which returns HTML.

Carles