本文整理汇总了C#中IHtmlHelper类的典型用法代码示例。如果您正苦于以下问题:C# IHtmlHelper类的具体用法?C# IHtmlHelper怎么用?C# IHtmlHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IHtmlHelper类属于命名空间,在下文中一共展示了IHtmlHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: BooleanTemplateCheckbox
private static IHtmlContent BooleanTemplateCheckbox(IHtmlHelper htmlHelper, bool value)
{
return htmlHelper.CheckBox(
expression: null,
isChecked: value,
htmlAttributes: CreateHtmlAttributes(htmlHelper, "check-box"));
}
开发者ID:phinq19,项目名称:git_example,代码行数:7,代码来源:DefaultEditorTemplates.cs
示例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();
}
}
开发者ID:LeoLcy,项目名称:MVC6Recipes,代码行数:30,代码来源:DataGridHelpers.cs
示例3: ComponentTagHelper
public ComponentTagHelper(IHttpContextAccessor contextAccessor, IBricsContextAccessor bricsContext)
{
_contextAccessor = contextAccessor;
_bricsContext = bricsContext;
_urlHelper = contextAccessor.HttpContext.RequestServices.GetService<IUrlHelper>();
_htmlHelper = contextAccessor.HttpContext.RequestServices.GetService<IHtmlHelper>();
}
开发者ID:marcuslindblom,项目名称:aspnet5,代码行数:7,代码来源:ComponentTagHelper.cs
示例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();
}
开发者ID:Nakro,项目名称:Mvc,代码行数:8,代码来源:DefaultEditorTemplates.cs
示例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);
}
开发者ID:mitsbits,项目名称:Ubik,代码行数:8,代码来源:BackofficePage.cs
示例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"));
}
开发者ID:phinq19,项目名称:git_example,代码行数:8,代码来源:DefaultEditorTemplates.cs
示例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);
}
开发者ID:zjean,项目名称:MVC6.Grid,代码行数:11,代码来源:HtmlGridTests.cs
示例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();
}
}
开发者ID:IRooc,项目名称:miniweb-coreclr,代码行数:12,代码来源:MiniWebSectionTagHelper.cs
示例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);
}
开发者ID:phinq19,项目名称:git_example,代码行数:12,代码来源:DefaultEditorTemplates.cs
示例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;
}
开发者ID:MvcControlsToolkit,项目名称:MvcControlsToolkit.ControlsCore,代码行数:13,代码来源:GridTagHelper.cs
示例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);
}
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:13,代码来源:DefaultDisplayTemplates.cs
示例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;
}
开发者ID:mitsbits,项目名称:Ubik.MVC5,代码行数:14,代码来源:StaticsHelper.cs
示例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;
}
开发者ID:4myBenefits,项目名称:Mvc,代码行数:14,代码来源:DefaultDisplayTemplates.cs
示例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;
}
开发者ID:4myBenefits,项目名称:Mvc,代码行数:14,代码来源:DefaultDisplayTemplates.cs
示例16: createPostBackLink
private static HtmlString createPostBackLink(IHtmlHelper helper,
string text,
string actionName,
string controller)
{
var vpc = new VirtualPathContext(
helper.ViewContext.HttpContext,
null,
(new RouteValueDictionary {
{ "controller", controller },
{ "action", actionName } })
);
var actionUrl = helper.ViewContext.RouteData.Routers[0].GetVirtualPath(vpc);
return new HtmlString(String.Format(@"<a href=""#"" class=""btn btn-default"" onclick=""wizard.WizardSubmit('{0}')"">{1}</a>",
actionUrl, text));
}
开发者ID:LeoLcy,项目名称:MVC6Recipes,代码行数:18,代码来源:WizardHelpers.cs
示例17: BooleanTemplateDropDownList
private static string BooleanTemplateDropDownList(IHtmlHelper htmlHelper, bool? value)
{
var selectTag = new TagBuilder("select", htmlHelper.HtmlEncoder);
selectTag.AddCssClass("list-box");
selectTag.AddCssClass("tri-state");
selectTag.Attributes["disabled"] = "disabled";
var builder = new StringBuilder();
builder.Append(selectTag.ToString(TagRenderMode.StartTag));
foreach (var item in TriStateValues(value))
{
var encodedText = htmlHelper.Encode(item.Text);
var option = DefaultHtmlGenerator.GenerateOption(item, encodedText, htmlHelper.HtmlEncoder);
builder.Append(option);
}
builder.Append(selectTag.ToString(TagRenderMode.EndTag));
return builder.ToString();
}
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:20,代码来源:DefaultDisplayTemplates.cs
示例18: GenerateTextBox
private static IHtmlContent GenerateTextBox(IHtmlHelper htmlHelper, object value, object htmlAttributes)
{
return htmlHelper.TextBox(
current: null,
value: value,
format: null,
htmlAttributes: htmlAttributes);
}
开发者ID:phinq19,项目名称:git_example,代码行数:8,代码来源:DefaultEditorTemplates.cs
示例19: ApplyRfc3339DateFormattingIfNeeded
private static void ApplyRfc3339DateFormattingIfNeeded(IHtmlHelper htmlHelper, string format)
{
if (htmlHelper.Html5DateRenderingMode != Html5DateRenderingMode.Rfc3339)
{
return;
}
var metadata = htmlHelper.ViewData.ModelMetadata;
var value = htmlHelper.ViewData.Model;
if (htmlHelper.ViewData.TemplateInfo.FormattedModelValue != value && metadata.HasNonDefaultEditFormat)
{
return;
}
if (value is DateTime || value is DateTimeOffset)
{
htmlHelper.ViewData.TemplateInfo.FormattedModelValue =
string.Format(CultureInfo.InvariantCulture, format, value);
}
}
开发者ID:phinq19,项目名称:git_example,代码行数:20,代码来源:DefaultEditorTemplates.cs
示例20: FileCollectionInputTemplate
public static IHtmlContent FileCollectionInputTemplate(IHtmlHelper htmlHelper)
{
if (htmlHelper == null)
{
throw new ArgumentNullException(nameof(htmlHelper));
}
var htmlAttributes =
CreateHtmlAttributes(htmlHelper, className: "text-box single-line", inputType: "file");
htmlAttributes["multiple"] = "multiple";
return GenerateTextBox(htmlHelper, htmlHelper.ViewData.TemplateInfo.FormattedModelValue, htmlAttributes);
}
开发者ID:phinq19,项目名称:git_example,代码行数:13,代码来源:DefaultEditorTemplates.cs
注:本文中的IHtmlHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论