views:

911

answers:

4

For some specific reasons, I need to use the jQuery 'load()' method in order to feed a webpage into a div layer.

Most of these webpages are plain .html files.

However for some, there is some data processing going on - I would like to be able to leverage the ASP.NET MVC model (which the site is built in) - but that's not possible with plain .html pages - so I need to use .aspx/.ascx.

I'm wondering if this is doable, does anyone know if I can load a layer that is retrieved from an .ascx ViewPage in ASP.NET MVC?

+1  A: 

You can create a render partial method for static html files also. You can check this question out on how: http://stackoverflow.com/questions/1196379/asp-net-mvc-renderpartial-for-a-static-html-file

Dale Ragan
No, this isn't quite what I mean... I have an html file, and within it, I need to draw a partial view, or call upon one. It can't be an .aspx/.ascx, it has to be a .html file.
Stacey
A: 

Unless I'm not understanding something, you could easily do this through a number of means.

For instance, you could setup a route of '....../{filename}.html' which spits out the HTML file as a string, you could convert all of the HTML files over to .ascx files and return a partial view.. and so on and so forth.

Chance
Can I bother you to elaborate on this? I'm very new to MVC's routing and what it can do/already does.
Stacey
The biggest reason I cannot use a static .html file is because I need to do some work with a view model in some situations.
Stacey
A: 

If I understand you well, all you have to do is to return

PartialView()

instead of

View()

(or whatever you return in normal conditions) in your called action.

eKek0
I cannot use PartialView, It isn't being returned to an MVC page, it's being returned to a plain, normal .html page. That's my problem.I need to draw a partial view inside of a normal .html page.
Stacey
+2  A: 

The html that you need to generate using the view model can be done in a partial view.

create the partial view (partialview.ascx) and in the controller create the method to get the actionresult

public ActionResult partialview(){ //your code return partialview(model); }

now in your html page, use a $.get("controller/partialview", {any data you want to send}, function(html){$("#divToLoad").html(html);});

Matt