本文整理汇总了C#中IHtmlHelper类的典型用法代码示例。如果您正苦于以下问题:C# IHtmlHelper类的具体用法?C# IHtmlHelper怎么用?C# IHtmlHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IHtmlHelper类属于命名空间,在下文中一共展示了IHtmlHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BooleanTemplateCheckbox
private static IHtmlContent BooleanTemplateCheckbox(IHtmlHelper htmlHelper, bool value)
{
return htmlHelper.CheckBox(
expression: null,
isChecked: value,
htmlAttributes: CreateHtmlAttributes(htmlHelper, "check-box"));
}
示例2: buildActionLink
private static string buildActionLink(IHtmlHelper helper,
string linkText,
int pageParam)
{
if (helper.ViewContext.HttpContext.Request.QueryString.HasValue)
{
var queryString = QueryHelpers.ParseQuery(helper.ViewContext.HttpContext.Request.QueryString.Value);
string[] sort, categoryId;
queryString.TryGetValue("SortExpression", out sort);
queryString.TryGetValue("CategoryId", out categoryId);
return helper.ActionLink(linkText,
helper.ViewContext.RouteData.Values["action"].ToString(),
new
{
SortExpression = sort,
CategoryId = categoryId,
Page = pageParam
}).ToString();
}
else
{
return helper.ActionLink(linkText,
helper.ViewContext.RouteData.Values["action"].ToString(),
new
{
Page = pageParam
}).ToString();
}
}
示例3: ComponentTagHelper
public ComponentTagHelper(IHttpContextAccessor contextAccessor, IBricsContextAccessor bricsContext)
{
_contextAccessor = contextAccessor;
_bricsContext = bricsContext;
_urlHelper = contextAccessor.HttpContext.RequestServices.GetService<IUrlHelper>();
_htmlHelper = contextAccessor.HttpContext.RequestServices.GetService<IHtmlHelper>();
}
示例4: BooleanTemplateDropDownList
private static string BooleanTemplateDropDownList(IHtmlHelper html, bool? value)
{
return html.DropDownList(
string.Empty,
DefaultDisplayTemplates.TriStateValues(value),
CreateHtmlAttributes(html, "list-box tri-state"))
.ToString();
}
示例5: AddBackofficeBottom
public void AddBackofficeBottom(string urlstring, IUrlHelper url, IHtmlHelper html)
{
const string prefix = @"~/Areas/Backoffice/Scripts/framework/";
urlstring = urlstring.TrimStart('/');
var path = string.Format("{0}{1}", url.Content(prefix), (urlstring.EndsWith(".js") ? urlstring : urlstring + ".js"));
html.Statics().FooterScripts.Add(path);
}
示例6: BooleanTemplateDropDownList
private static IHtmlContent BooleanTemplateDropDownList(IHtmlHelper htmlHelper, bool? value)
{
return htmlHelper.DropDownList(
expression: null,
selectList: DefaultDisplayTemplates.TriStateValues(value),
optionLabel: null,
htmlAttributes: CreateHtmlAttributes(htmlHelper, "list-box tri-state"));
}
示例7: HtmlGridTests
public HtmlGridTests()
{
html = Substitute.For<IHtmlHelper>();
html.ViewContext.Returns(new ViewContext());
html.ViewContext.HttpContext = new DefaultHttpContext();
grid = new Grid<GridModel>(new GridModel[8]);
htmlGrid = new HtmlGrid<GridModel>(html, grid);
grid.Columns.Add(model => model.Name);
grid.Columns.Add(model => model.Sum);
}
示例8: SectionContent
private static string SectionContent(IHtmlHelper html, ISitePage sitepage, IPageSection model)
{
using (StringWriter result = new StringWriter())
{
foreach (var item in model.Items)
{
item.Page = sitepage;
html.Partial(item.Template, item).WriteTo(result, HtmlEncoder.Default);
}
return result.ToString();
}
}
示例9: BooleanTemplate
public static IHtmlContent BooleanTemplate(IHtmlHelper htmlHelper)
{
bool? value = null;
if (htmlHelper.ViewData.Model != null)
{
value = Convert.ToBoolean(htmlHelper.ViewData.Model, CultureInfo.InvariantCulture);
}
return htmlHelper.ViewData.ModelMetadata.IsNullableValueType ?
BooleanTemplateDropDownList(htmlHelper, value) :
BooleanTemplateCheckbox(htmlHelper, value ?? false);
}
示例10: GridTagHelper
public GridTagHelper(IOptions<MvcViewOptions> optionsAccessor,
IHtmlHelper html,
IHttpContextAccessor httpAccessor, IViewComponentHelper component,
IUrlHelperFactory urlHelperFactory,
IStringLocalizerFactory factory)
{
IdAttributeDotReplacement = optionsAccessor.Value.HtmlHelperOptions.IdAttributeDotReplacement;
this.html = html;
this.httpAccessor = httpAccessor;
this.component = component;
this.urlHelperFactory = urlHelperFactory;
this.factory = factory;
}
示例11: getEnumDisplayName
//workaround forr issue https://github.com/aspnet/Mvc/issues/2430
private static string getEnumDisplayName(Type type, string o, IHtmlHelper h)
{
string displayName = null;
foreach (SelectListItem item in h.GetEnumSelectList(type))
{
if (o == item.Value)
{
displayName = item.Text ?? item.Value;
}
}
return displayName;
}
开发者ID:MvcControlsToolkit,项目名称:MvcControlsToolkit.ControlsCore,代码行数:14,代码来源:DefaultServerControlsTagHelpersProvider.cs
示例12: BooleanTemplateCheckbox
private static string BooleanTemplateCheckbox(bool value, IHtmlHelper htmlHelper)
{
var inputTag = new TagBuilder("input", htmlHelper.HtmlEncoder);
inputTag.AddCssClass("check-box");
inputTag.Attributes["disabled"] = "disabled";
inputTag.Attributes["type"] = "checkbox";
if (value)
{
inputTag.Attributes["checked"] = "checked";
}
return inputTag.ToString(TagRenderMode.SelfClosing);
}
示例13: GetInstance
public static StaticsHelper GetInstance(IHtmlHelper htmlHelper)
{
const string instanceKey = "8F3AC534-E5B1-4C51-B5A9-ED0EAC731633";
var context = htmlHelper.ViewContext.HttpContext;
if (context == null) return null;
var assetsHelper = (StaticsHelper)context.Items[instanceKey];
if (assetsHelper == null)
context.Items.Add(instanceKey, assetsHelper = new StaticsHelper());
return assetsHelper;
}
示例14: BooleanTemplateCheckbox
private static IHtmlContent BooleanTemplateCheckbox(bool value, IHtmlHelper htmlHelper)
{
var inputTag = new TagBuilder("input");
inputTag.AddCssClass("check-box");
inputTag.Attributes["disabled"] = "disabled";
inputTag.Attributes["type"] = "checkbox";
if (value)
{
inputTag.Attributes["checked"] = "checked";
}
inputTag.TagRenderMode = TagRenderMode.SelfClosing;
return inputTag;
}
示例15: BooleanTemplateDropDownList
private static IHtmlContent BooleanTemplateDropDownList(IHtmlHelper htmlHelper, bool? value)
{
var selectTag = new TagBuilder("select");
selectTag.AddCssClass("list-box");
selectTag.AddCssClass("tri-state");
selectTag.Attributes["disabled"] = "disabled";
foreach (var item in TriStateValues(value))
{
selectTag.InnerHtml.Append(DefaultHtmlGenerator.GenerateOption(item, item.Text));
}
return selectTag;
}