如何将部分视图呈现为字符串

我有以下代码:


public ActionResult SomeAction()

{

    return new JsonpResult

    {

        Data = new { Widget = "some partial html for the widget" }

    };

}

我想对其进行修改,以便可以


public ActionResult SomeAction()

{

    // will render HTML that I can pass to the JSONP result to return.

    var partial = RenderPartial(viewModel); 

    return new JsonpResult

    {

        Data = new { Widget = partial }

    };

}

这可能吗?有人可以解释一下吗?


注意,我在发布解决方案之前编辑了问题。


慕工程0101907
浏览 361回答 3
3回答
打开App,查看更多内容
随时随地看视频慕课网APP