本文整理汇总了C#中Microsoft.AspNet.Razor.TagHelpers.TagHelperContext.HasInputGroupAddonContext方法的典型用法代码示例。如果您正苦于以下问题:C# TagHelperContext.HasInputGroupAddonContext方法的具体用法?C# TagHelperContext.HasInputGroupAddonContext怎么用?C# TagHelperContext.HasInputGroupAddonContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.AspNet.Razor.TagHelpers.TagHelperContext
的用法示例。
在下文中一共展示了TagHelperContext.HasInputGroupAddonContext方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BootstrapProcess
protected override void BootstrapProcess(TagHelperContext context, TagHelperOutput output) {
context.SetButtonGroupContext(this);
output.Attributes.Add("role", "group");
if (context.HasInputGroupContext())
{
Size = BootstrapTagHelpers.Size.Default;
if (!context.HasInputGroupAddonContext())
{
output.TagName = "span";
output.AddCssClass("input-group-btn");
}
context.RemoveInputGroupContext();
}
else {
output.TagName = "div";
if (Vertical)
output.AddCssClass("btn-group-vertical");
else
output.AddCssClass("btn-group");
if (Size.HasValue)
output.AddCssClass("btn-group-" + Size.Value.GetDescription());
if (Justified)
output.AddCssClass("btn-group-justified");
}
}
示例2: 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>");
}
示例3: BootstrapProcess
protected override void BootstrapProcess(TagHelperContext context, TagHelperOutput output) {
output.AddCssClass("btn");
output.AddCssClass("btn-" + (Context ?? ButtonContext.Default).ToString().ToLower());
if (context.HasInputGroupContext()) {
Size=BootstrapTagHelpers.Size.Default;
if (!context.HasInputGroupAddonContext()) {
output.PreElement.PrependHtml("<span class=\"input-group-btn\">");
output.PostElement.AppendHtml("</span>");
}
}
if (WrapInButtonGroup ||
!output.TagName.Equals("a", StringComparison.CurrentCultureIgnoreCase) && ButtonGroupJustified) {
if (Size.HasValue && Size.Value != BootstrapTagHelpers.Size.Default)
output.PreElement.SetHtmlContent(
$"<div class=\"btn-group btn-group-{Size.Value.GetDescription()}\" role=\"group\">");
else
output.PreElement.SetHtmlContent(
$"<div class=\"btn-group\" role=\"group\">");
output.PostElement.SetHtmlContent("</div>");
}
else if (Size.HasValue && Size.Value != BootstrapTagHelpers.Size.Default)
output.AddCssClass("btn-" + Size.Value.GetDescription());
if (BlockStyle)
output.AddCssClass("btn-block");
if (Pressed) {
output.AddAriaAttribute("pressed", "true");
output.AddCssClass("active");
}
if (Disabled) {
if (output.TagName == "a") {
output.AddCssClass("disabled");
if (context.AllAttributes.ContainsName("href")) {
output.Attributes.RemoveAll("href");
output.Attributes.Add("data-href", context.AllAttributes["href"].Value);
}
}
output.MergeAttribute("role", "button");
}
}
示例4: ProcessCheckControl
private void ProcessCheckControl(TagHelperContext context, TagHelperOutput output) {
if (InputGroupContext != null) {
output.PreElement.Append(Label);
if (!context.HasInputGroupAddonContext()) {
output.PreElement.AppendHtml("<span class=\"input-group-addon\">");
output.PostElement.PrependHtml("</span>");
}
}
else if (IsInLabel)
output.PostElement.Append(Label);
else
LabelTagHelper.WrapInLabel(output, Label, null, FormContext);
if (!string.IsNullOrEmpty(HelpText))
if (InputGroupContext != null)
InputGroupContext.Output.PostElement.AppendHtml(HelpBlockTagHelper.GenerateHelpBlock(HelpText));
else
output.PostElement.AppendHtml(HelpBlockTagHelper.GenerateHelpBlock(HelpText));
if (!IsInLabel) {
output.PreElement.PrependHtml(FormContext?.Inline ?? false
? $"<div class=\"{Type.ToLower()}-inline\">"
: $"<div class=\"{Type.ToLower()}\">");
output.PostElement.AppendHtml("</div>");
if (FormGroupContext != null)
FormGroupContext.WrapInDivForHorizontalForm(output, false);
else if (FormContext != null)
FormContext.WrapInDivForHorizontalForm(output, false);
}
}