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


C# IHtmlHelper类代码示例

本文整理汇总了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"));
 }
开发者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


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