当前位置: 首页>>代码示例>>C#>>正文


C# HtmlHelper.Partial方法代码示例

本文整理汇总了C#中System.Web.Mvc.HtmlHelper.Partial方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlHelper.Partial方法的具体用法?C# HtmlHelper.Partial怎么用?C# HtmlHelper.Partial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.Mvc.HtmlHelper的用法示例。


在下文中一共展示了HtmlHelper.Partial方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenderPartial

        /// <summary>
        /// Renders the fieldset partial
        /// </summary>
        /// <param name="htmlHelper">The HTML helper.</param>
        /// <param name="fieldsetModel"></param>
        /// <param name="partialPath">The partial path.</param>
        /// <param name="viewDataDictionary">The view data dictionary.</param>
        /// <returns></returns>
        private static IHtmlString RenderPartial(HtmlHelper htmlHelper, ArchetypeFieldsetModel fieldsetModel, string partialPath, ViewDataDictionary viewDataDictionary)
        {
            var context = HttpContext.Current;

            if (fieldsetModel == null || context == null)
            {
                return new HtmlString("");
            }

            var sb = new StringBuilder();

            var pathToPartials = "~/Views/Partials/Archetype/";
            if (!string.IsNullOrEmpty(partialPath))
            {
                pathToPartials = partialPath;
            }

            var partial = pathToPartials + fieldsetModel.Alias + ".cshtml";

            if (System.IO.File.Exists(context.Server.MapPath(partial)))
            {
                sb.AppendLine(htmlHelper.Partial(partial, fieldsetModel, viewDataDictionary).ToString());
            }
            else
            {
                LogHelper.Info<ArchetypeModel>(string.Format("The partial for {0} could not be found.  Please create a partial with that name or rename your alias.", context.Server.MapPath(partial)));
            }

            return new HtmlString(sb.ToString());
        }
开发者ID:idontbyte,项目名称:Archetype,代码行数:38,代码来源:HtmlHelperExtensions.cs

示例2: Render

        private IHtmlString Render(ShapeDescriptor shapeDescriptor, DisplayContext displayContext, HarvestShapeInfo harvestShapeInfo, HarvestShapeHit harvestShapeHit) {
            Logger.Information("Rendering template file '{0}'", harvestShapeInfo.TemplateVirtualPath);
            IHtmlString result;

            if (displayContext.ViewContext.View != null) {
                var htmlHelper = new HtmlHelper(displayContext.ViewContext, displayContext.ViewDataContainer);
                result = htmlHelper.Partial(harvestShapeInfo.TemplateVirtualPath, displayContext.Value);
            }
            else {
                // If the View is null, it means that the shape is being executed from a non-view origin / where no ViewContext was established by the view engine, but manually.
                // Manually creating a ViewContext works when working with Shape methods, but not when the shape is implemented as a Razor view template.
                // Horrible, but it will have to do for now.
                result = RenderRazorViewToString(harvestShapeInfo.TemplateVirtualPath, displayContext);
            }

            Logger.Information("Done rendering template file '{0}'", harvestShapeInfo.TemplateVirtualPath);
            return result;
        }
开发者ID:jdages,项目名称:AndrewsHouse,代码行数:18,代码来源:ShapeTemplateBindingStrategy.cs

示例3: Render

 public static IHtmlString Render(this PropertyVm propertyVm, HtmlHelper html)
 {
     return (html.Partial("FormFactory/Form.Property", propertyVm));
 }
开发者ID:ccjchina,项目名称:FormFactory,代码行数:4,代码来源:PropertyRenderExtension.cs

示例4: Render

 public IHtmlString Render(HtmlHelper html)
 {
     return html.Partial("Tweets", this);
 }
开发者ID:benfoster,项目名称:CompositeMVCPrototype,代码行数:4,代码来源:TwitterWidget.cs

示例5: Render

        private IHtmlString Render(DisplayContext displayContext, HarvestShapeInfo harvestShapeInfo)
        {
            Logger.Information("渲染模板文件 '{0}'", harvestShapeInfo.TemplateVirtualPath);
            IHtmlString result;

            if (displayContext.ViewContext.View != null)
            {
                var htmlHelper = new HtmlHelper(displayContext.ViewContext, displayContext.ViewDataContainer);
                result = htmlHelper.Partial(harvestShapeInfo.TemplateVirtualPath, displayContext.Value);
            }
            else
            {
                //如果视图为空,则表示该造型是从一个非视图产地/在没有的ViewContext成立了由视图引擎,但是手动执行。
                //手动创建的ViewContext工程与形状的方法工作时,而不是当形状被实现为一个Razor视图模板。
                //可怕的,但它会做现在。
                result = RenderRazorViewToString(harvestShapeInfo.TemplateVirtualPath, displayContext);
            }

            Logger.Information("完成目标文件 '{0}' 的渲染。", harvestShapeInfo.TemplateVirtualPath);
            return result;
        }
开发者ID:l1183479157,项目名称:RabbitHub,代码行数:21,代码来源:ShapeTemplateBindingStrategy.cs


注:本文中的System.Web.Mvc.HtmlHelper.Partial方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。