本文整理汇总了C#中Microsoft.AspNet.Razor.TagHelpers.TagHelperContext.HasNavContext方法的典型用法代码示例。如果您正苦于以下问题:C# TagHelperContext.HasNavContext方法的具体用法?C# TagHelperContext.HasNavContext怎么用?C# TagHelperContext.HasNavContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.AspNet.Razor.TagHelpers.TagHelperContext
的用法示例。
在下文中一共展示了TagHelperContext.HasNavContext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BootstrapProcess
protected override void BootstrapProcess(TagHelperContext context, TagHelperOutput output) {
bool hasNavContext = context.HasNavContext();
if (hasNavContext) {
output.TagName = "li";
output.Attributes.Add("role", "presentation");
Context = null;
Splitted = false;
}
else {
output.TagName = "div";
output.AddCssClass("btn-group");
if (Size.HasValue && Size != BootstrapTagHelpers.Size.Default)
output.AddCssClass("btn-group-" + Size.Value.GetDescription());
}
if (context.HasInputGroupContext()) {
Size = BootstrapTagHelpers.Size.Default;
if (!context.HasInputGroupAddonContext()) {
output.TagName = "span";
output.AddCssClass("input-group-btn");
}
}
if (Dropup)
output.AddCssClass("dropup");
var buttonBuilder = new TagBuilder(Href == null && !hasNavContext ? "button" : "a");
buttonBuilder.InnerHtml.AppendHtml(Text);
if (!hasNavContext) {
buttonBuilder.AddCssClass("btn");
buttonBuilder.AddCssClass("btn-" + (Context ?? ButtonContext.Default).ToString().ToLower());
if (Href == null)
buttonBuilder.Attributes.Add("type", "button");
if (ButtonId != null)
buttonBuilder.Attributes.Add("id", ButtonId);
else {
buttonBuilder.Attributes.Add("href", Href);
if (!Splitted)
buttonBuilder.Attributes.Add("role", "button");
}
}
else {
buttonBuilder.Attributes.Add("href",Href);
}
if (Splitted) {
output.PreContent.Append(buttonBuilder);
buttonBuilder = new TagBuilder("button") {
Attributes = {
{"type", "button"},
{"class", "btn btn-" + (Context ?? ButtonContext.Default).ToString().ToLower()}
}
};
}
else
buttonBuilder.InnerHtml.AppendHtml(" ");
buttonBuilder.AddCssClass("dropdown-toggle");
buttonBuilder.Attributes.Add("data-toggle", "dropdown");
buttonBuilder.Attributes.Add("aria-haspopup", "true");
buttonBuilder.Attributes.Add("aria-expanded", "false");
buttonBuilder.InnerHtml.AppendHtml("<span class=\"caret\">");
output.PreContent.Append(buttonBuilder);
output.PreContent.AppendHtml(RightAligned
? "<ul class=\"dropdown-menu dropdown-menu-right\">"
: "<ul class=\"dropdown-menu\">");
output.PostContent.AppendHtml("</ul>");
}