tags:

views:

35

answers:

2

Is it possible to render a view from a class, which is not controller?

For example, I'm having a class which will return some data, like controls, which i want to derive from my view.

Is it possible?

Thanks in advance.

A: 

If you want to render a view into a string you might find this article useful.

Darin Dimitrov
A: 

In a view, we have a method named Html.Partial which renders a partial to a string. Within your controller, you can instantiate an HtmlHelper instance and then call the Partial extension method on it. Make sure you import the System.Web.Mvc.Html namespace in your controller.

Haacked