我正在扩展 htmlhelper。但我无法调用它的渲染 Action 。
using System.Text;
using System.Web.Mvc;
using System.Web.Mvc.Html;
public static class ViewHelpers
{
public static string Text(this HtmlHelper htmlHelper, string name, object value, bool isEditMode)
{
htmlHelper.RenderAction(...) //cannot be called
}
}
我如何调用RenderAction???
最佳答案
CoffeeCode 的方向是正确的,但要包含的命名空间应该是 System.Web、System.Web.Mvc 和 System.Web.Mvc。 Html。
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using System.Resources;
using System.Web.Routing;
using System.Text.RegularExpressions;
namespace xxx.yyy.Helpers {
public static class HelperView {
public static void RenderHeader(this HtmlHelper helper) {
helper.RenderAction("Header", "Default", new { pageAction = helper.ViewContext.RouteData.Values["action"].ToString() });
}
}
}
http://msdn.microsoft.com/en-us/library/ee703490(v=vs.108).aspx
关于.net - 如何在我的 Html Helper 中调用 RenderAction?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2285344/