.net - 如何在我的 Html Helper 中调用 RenderAction?

标签 .net asp.net asp.net-mvc html-helper

我正在扩展 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.WebSystem.Web.MvcSystem.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/

相关文章:

.net - LinkPoint 支付与 IIS7 的集成导致 w3wp.exe 崩溃

c# - WPF 绑定(bind)到集合中多个对象的相同属性

asp.net - System.Web.UI.DataVisualization.Charting.Grid 在 GAC 中存在两次

asp.net-mvc - MVC 3 自定义模板和 EditorForModel 混淆

asp.net - Web API 授权属性不适用于操作

c# - 如何设计可重复使用的上下文菜单?

.net - 类型类有什么问题?

asp.net - Azure 和独立 SQL Server 上的 SqlMembership

asp.net - 使用 TFS 进行 MSBuild 在使用多个项目进行 ASP.NET 部署时失败

asp.net-mvc - MVC 架构中的项目何时应该拥有自己的 Controller ?