I have a class and call it from a razor viewpage in asp.net mvc3.
How can i pass the HtmlHelper from the View to my class ?
I can do this but then ive got not all methods for example “RenderAction” and “RenderPartial”
are missing.
Update
I want to call a Partial View because its easier to implement (by the end user) and doesnt require a complete compilation of my site.
please note that the following example is NOT excactly what i want to do 😉 I think my example is stupid, but it shows in generall what i want to do.
ViewPage:
HtmlString str = new Renderer().Render(this.Html)
Code (behind):
public class Renderer
{
HtmlHelper _html;
public Renderer(HtmlHelper html)
{
this._html = html;
}
public HtmlString Render()
{
string result = string.Empty;
// getting html from a partial view
return new HtmlString(result);
}
}
The Problem was missing usings.
makes the Methods visible Everything else was unnecessary.