本文整理汇总了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());
}
示例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;
}
示例3: Render
public static IHtmlString Render(this PropertyVm propertyVm, HtmlHelper html)
{
return (html.Partial("FormFactory/Form.Property", propertyVm));
}
示例4: Render
public IHtmlString Render(HtmlHelper html)
{
return html.Partial("Tweets", this);
}
示例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;
}