Render partial in an extension method fails

Mic*_*elD 3 .net c# asp.net-mvc asp.net-mvc-2

I'm creating a tabcontainer that shows information from partials. The code that i've created is as follows:

//Entering extension method, m_helper is of type HtmlHelper
foreach (var tab in m_tabList)
{
    sb.AppendLine("<div class='tabContent'>"); 
    m_helper.RenderPartial(tab.PartialName);
    sb.AppendLine("</div>");    
}
//Returning sb.ToString to the caller method
Run Code Online (Sandbox Code Playgroud)

This will not work because the renderpartial writes directly to the output stream. I cannot render the partial to a string either. to add it to the stringbuilder object.

Any suggestions?

Ami*_*abh 5

使用

m_helper.Partial(tab.PartialName);
Run Code Online (Sandbox Code Playgroud)

这将返回MvcHtmlString.