开发者

Render partial in an extension method fails

开发者 https://www.devze.com 2023-01-05 17:32 出处:网络
I\'m creating a tabcontainer that shows information from partials. The code that i\'ve created is as follows:

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

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?


use

m_helper.Partial(tab.PartialName);

This will return MvcHtmlString.

0

精彩评论

暂无评论...
验证码 换一张
取 消