本文整理汇总了C#中HtmlTags.HtmlTag类的典型用法代码示例。如果您正苦于以下问题:C# HtmlTag类的具体用法?C# HtmlTag怎么用?C# HtmlTag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HtmlTag类属于HtmlTags命名空间,在下文中一共展示了HtmlTag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Checkbox
private static HtmlTag Checkbox(UIComponentContext context)
{
var checkbox = new CheckboxTag(context.Value<bool>()).Attr("value", "true");
var hidden = new HtmlTag("input").Attr("type", "hidden").Attr("value", "false");
checkbox.Next = hidden;
return checkbox;
}
示例2: AddElementName
public static void AddElementName(ElementRequest request, HtmlTag tag)
{
if (tag.IsInputElement())
{
tag.Attr("name", request.ElementId);
}
}
示例3: AuthButtons
public static MvcHtmlString AuthButtons(this HtmlHelper htmlHelper)
{
var authContainer =
new HtmlTag("div")
.Attr("style", "overflow: hidden;")
.Append("input",
ht => ht.Id("authType").Attr("name", "authType").Attr("type", "hidden").Attr("value", "1"))
.Append("a",
ht => ht
.Attr("href", "javascript:auth.signin('twitter')")
.AddClasses("simpleAuthButton", "twitter")
.Text("twitter"))
.Append("a",
ht => ht
.Attr("href", "javascript:auth.signin('facebook')")
.AddClasses("simpleAuthButton", "facebook")
.Text("facebook"))
.Append("a",
ht => ht
.Attr("href", "javascript:auth.signin('google')")
.AddClasses("simpleAuthButton", "google")
.Text("google"))
.ToHtmlString();
return new MvcHtmlString(authContainer);
}
示例4: TestEditorTag
public TestEditorTag(FixtureLibrary library)
: base("div")
{
AddClass("main");
Add("h2").AddClass(HtmlClasses.TEST_NAME);
Id("testEditor");
AddClass(HtmlClasses.TEST_EDITOR);
_container = Add("div").AddClasses("container", HtmlClasses.SECTION, "test-editor");
FixtureGraph fixture = library.BuildTopLevelGraph();
HtmlTag holder = new HolderTag(fixture).AddClass("top-level-holder");
holder.Children.Last().Render(false);
Container
.MetaData(GrammarConstants.LEAF_NAME, GrammarConstants.TEST)
.MetaData(GrammarConstants.FIXTURE, GrammarConstants.TEST)
.MetaData(GrammarConstants.SELECTION_MODE, SelectionMode.OneOrMore.ToString())
.Append(holder)
.Append(new HtmlTag("hr"));
Container.ActionLink(fixture.Policies.AddGrammarText, GrammarConstants.ADD_SECTION_ACTIVATOR);
Container.Append(new GrammarSelector(fixture).Build());
}
示例5: mustache_attr
public void mustache_attr()
{
var tag = new HtmlTag("a");
tag.MustacheAttr("href", "url");
tag.ToString().ShouldEqual("<a href=\"{{url}}\"></a>");
}
示例6: Build
public override HtmlTag Build(ElementRequest request)
{
HtmlTag root = new HtmlTag("div").Attr("data-bind", "foreach: "+ CCHtmlConventions2.DeriveElementName(request));
var child = new HtmlTag("div").Attr("data-bind", "text: $data" );
root.Append(child);
return root;
}
示例7: Modify
public virtual void Modify(HtmlTag form)
{
if (!_modify) return;
form.Data("validation-mode", _value.ToLower());
form.AddClass("validated-form");
}
示例8: RenderAuthWarnings
public static MvcHtmlString RenderAuthWarnings(this HtmlHelper htmlHelper)
{
var appSettingsKeys =
new[]
{
"googleAppID", "googleAppSecret",
"facebookAppID", "facebookAppSecret",
"twitterConsumerKey", "twitterConsumerSecret"
};
var noValueForSetting = appSettingsKeys
.Any(key => string.IsNullOrEmpty(ConfigurationManager.AppSettings[key]));
var message = "";
if (noValueForSetting)
{
message = new HtmlTag("p")
.Attr("style", "color: Red;")
.Text("Not all key and secrets are filled in a configuration file.")
.ToHtmlString();
}
return new MvcHtmlString(message);
}
示例9: Build
public override HtmlTag Build(ElementRequest request)
{
var tag = new HtmlTag("div").Text(request.StringValue()).AddClass("editable").Id(request.Accessor.Name);
var options = new EditOptions();
if (request.Accessor.HasAttribute<MarkdownAttribute>())
{
tag.UnEncoded().Text(new Markdown().Transform(request.RawValue== null ? "" : request.RawValue.ToString()));
options.Markdown = true;
}
options.MultiLine = request.Accessor.Name == "Details";
options.RequiresExplicitUserActionForSave = true;
options.MaximumLength = request.Accessor.PropertyType.Equals(typeof(string)) ? Entity.UnboundedStringLength : 0;
options.IsDate = request.Accessor.PropertyType.IsDateTime();
options.IsTime = request.Accessor.Name.ToLower().Contains("time");
options.IsNumber = request.Accessor.PropertyType.IsIntegerBased() || request.Accessor.PropertyType.IsFloatingPoint();
options.Required = request.Accessor.HasAttribute<RequiredAttribute>();
options.PlaceholderText = "Double-Click to edit " + request.Accessor.Name.ToLower() + ".";
var data = options.ToJson();
tag.Attr("data", "{editoptions:"+data+"}");
return tag;
}
示例10: Build
public override void Build(ElementRequest request, HtmlTag tag)
{
tag
.AllTags()
.Where(t => t.IsInputElement())
.ForEach(t => t.AddClass("url"));
}
示例11: setDisabledState
private static void setDisabledState(MenuItemToken item, HtmlTag link)
{
if (item.MenuItemState == MenuItemState.Disabled)
{
link.AddClass("disabled");
}
}
示例12: ScriptTag
public ScriptTag(string mode, Func<string, string> toFullUrl, Asset asset, string defaultUrl = null)
: base("script")
{
// http://stackoverflow.com/a/1288319/75194
Attr("type", "text/javascript");
if (asset == null)
{
Attr("src", toFullUrl(defaultUrl));
return;
}
if (asset.CdnUrl.IsNotEmpty())
{
Attr("src", asset.CdnUrl);
if (asset.FallbackTest.IsNotEmpty() && asset.File != null)
{
Next = new HtmlTag("script");
var text = "if ({0}) document.write(unescape(\"%3Cscript src='{1}' type='text/javascript'%3E%3C/script%3E\"));".ToFormat(asset.FallbackTest, asset.Url);
Next.Encoded(false);
Next.Text(text);
}
return;
}
var url = asset.Url;
if (mode.InDevelopment() && asset.File != null)
{
url += "?Etag=" + asset.File.Etag();
}
Attr("src", toFullUrl(url));
}
示例13: get_conventions
public ConventionsViewModel get_conventions()
{
var configTypes = new string[]
{
ConfigurationType.Settings,
ConfigurationType.Discovery,
ConfigurationType.Explicit,
ConfigurationType.Policy,
ConfigurationType.Attributes,
ConfigurationType.ModifyRoutes,
ConfigurationType.InjectNodes,
ConfigurationType.Conneg,
ConfigurationType.Attachment,
ConfigurationType.Navigation,
ConfigurationType.ByNavigation,
ConfigurationType.Reordering,
ConfigurationType.Instrumentation
};
var tag = new HtmlTag("ul");
configTypes.Each(configType => {
tag.Add("li/a").Text(configType).Attr("href", "#" + configType);
});
return new ConventionsViewModel
{
Descriptions = new TagList(configTypes.Select(configType => new ConfigurationTypeTag(configType, _graph))),
TableOfContents = tag
};
}
示例14: TableTag
public TableTag()
: base("table")
{
_header = new HtmlTag("thead", this);
_footer = new HtmlTag("tfoot", this).Render(false);
_body = new HtmlTag("tbody", this);
}
示例15: AddElementName
public static void AddElementName(ElementRequest request, HtmlTag tag)
{
if (tag.IsInputElement())
{
tag.Attr(HtmlAttributeConstants.Name, request.ElementId);
}
}