本文整理汇总了C#中HtmlTextWriterTag类的典型用法代码示例。如果您正苦于以下问题:C# HtmlTextWriterTag类的具体用法?C# HtmlTextWriterTag怎么用?C# HtmlTextWriterTag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HtmlTextWriterTag类属于命名空间,在下文中一共展示了HtmlTextWriterTag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddTag
public static void AddTag(this HtmlTextWriter writer, HtmlTextWriterTag tag,
string value = "")
{
writer.RenderBeginTag(tag);
writer.Write(value != "" ? value : Environment.NewLine);
writer.RenderEndTag();
}
示例2: Full
public static HtmlTextWriter Full(this HtmlTextWriter writer, HtmlTextWriterTag tag, string content = "")
{
writer.RenderBeginTag(tag);
writer.Write(content);
writer.RenderEndTag();
return writer;
}
示例3: BuildOneTag
internal static string BuildOneTag(string virtualPath, HtmlTextWriterTag tag)
{
TagRenderMode tagRenderMode;
var tagBuilder = new TagBuilder(tag.ToString().ToLower());
var absolutePath = VirtualPathUtility.ToAbsolute(virtualPath);
switch (tag)
{
case HtmlTextWriterTag.Script:
tagRenderMode = TagRenderMode.Normal;
tagBuilder.MergeAttribute("type", "text/javascript");
tagBuilder.MergeAttribute("src", absolutePath);
break;
case HtmlTextWriterTag.Link:
tagRenderMode = TagRenderMode.SelfClosing;
tagBuilder.MergeAttribute("type", "text/css");
tagBuilder.MergeAttribute("media", "all"); //always ALL?
tagBuilder.MergeAttribute("rel", "stylesheet");
tagBuilder.MergeAttribute("href", absolutePath);
break;
default:
throw new InvalidOperationException();
}
return tagBuilder.ToString(tagRenderMode);
}
示例4: RenderTag
public void RenderTag(HtmlTextWriterTag tagKey, string html)
{
RenderBeginTag(tagKey);
if (!string.IsNullOrEmpty(html))
Write(html);
RenderEndTag();
}
示例5: RenderTag
public static IDisposable RenderTag([NotNull] this HtmlTextWriter writer, HtmlTextWriterTag tag)
{
if (writer == null) throw new ArgumentNullException("writer");
writer.RenderBeginTag(tag);
return new DisposableAction(writer.RenderEndTag);
}
示例6: HtmlTag
/// <summary>
/// Initializes a new instance of the HtmlTag class. Renders the opening tag of an HTML node, including any attributes.
/// </summary>
/// <param name="writer">
/// The HTMLTextWriter.
/// </param>
/// <param name="tag">
/// The type of HTML tag.
/// </param>
/// <param name="style">
/// The style.
/// </param>
/// <param name="attributes">
/// HTML attributes.
/// </param>
public HtmlTag(HtmlTextWriter writer, HtmlTextWriterTag tag, TagStyle style, params HtmlAttribute[] attributes)
{
this.writer = writer;
this.attributes = attributes;
this.tag = tag.ToString().ToLower();
this.tagStyle = style;
this.StartRender();
}
示例7: InsertText
/// <summary>
/// Write text inside tags of type HtmlTextWriterTag
/// </summary>
/// <param name="html">HtmlTextWriter instance object</param>
/// <param name="value">Input text / string</param>
/// <param name="tag">Value of HtmlTextWriterTag enumaration</param>
/// <returns>HtmlTextWriter reference</returns>
public static HtmlTextWriter InsertText(this HtmlTextWriter html, string value, HtmlTextWriterTag tag)
{
CheckNullParam(html);
html.WriteBeginTag(tag.ToString());
html.Write(HtmlTextWriter.TagRightChar);
html.Write(value);
html.WriteEndTag(tag.ToString());
return html;
}
示例8: BuildTags
internal static MvcHtmlString BuildTags(string[] virtualPaths, HtmlTextWriterTag tag)
{
var builder = new StringBuilder();
foreach (var virtualPath in virtualPaths)
{
var urls = ResolveUrls(virtualPath);
foreach (var url in urls)
builder.AppendLine(BuildOneTag(url, tag));
}
return MvcHtmlString.Create(builder.ToString());
}
示例9: Test
private void Test(ref HtmlTextWriterTag testTag)
{
try
{
this.GHTSubTestBegin("Tag = " + ((HtmlTextWriterTag) testTag).ToString());
WebControl control1 = new WebControl(testTag);
this.m_ctrlCounter++;
control1.ID = "ctrl_" + this.m_ctrlCounter.ToString();
base.GHTActiveSubTest.Controls.Add(control1);
}
catch (Exception exception2)
{
// ProjectData.SetProjectError(exception2);
Exception exception1 = exception2;
this.GHTSubTestUnexpectedExceptionCaught(exception1);
// ProjectData.ClearProjectError();
}
this.GHTSubTestEnd();
}
示例10: WebControl
public WebControl (HtmlTextWriterTag tag)
{
this.tag = tag;
this.enabled = true;
}
示例11: RenderElement
internal static void RenderElement(this HtmlTextWriter writer, HtmlTextWriterTag tag, string format, params object[] arg)
{
writer.RenderBeginTag(tag);
writer.Write(format, arg);
writer.RenderEndTag();
}
示例12: RenderBeginTag
public override void RenderBeginTag (HtmlTextWriterTag tagKey)
{
base.RenderBeginTag (tagKey);
}
示例13: ScriptControlBase
/// <summary>
/// 构造函数
/// Initializes a new ScriptControl
/// </summary>
/// <param name="enableClientState">是否使用ClientState</param>
/// <param name="tag">控件的HtmlTextWriterTag</param>
protected ScriptControlBase(bool enableClientState, HtmlTextWriterTag tag)
{
_tagKey = tag;
_enableClientState = enableClientState;
}
示例14: RenderBeginTag
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public override void RenderBeginTag(HtmlTextWriterTag tagKey) {
// flush string buffers to build new tag
_beforeTag.Length = 0;
_beforeContent.Length = 0;
_afterContent.Length = 0;
_afterTag.Length = 0;
_renderFontTag = false;
_fontFace = null;
_fontColor = null;
_fontSize = null;
// div->table substitution.
if (ShouldPerformDivTableSubstitution) {
if (tagKey == HtmlTextWriterTag.Div) {
AppendOtherTag("tr", _beforeContent, _afterContent);
string alignment;
if (IsAttributeDefined(HtmlTextWriterAttribute.Align, out alignment)) {
string[] attribs = new string[] { GetAttributeName(HtmlTextWriterAttribute.Align), alignment};
AppendOtherTag("td", new object[]{ attribs}, _beforeContent, _afterContent);
}
else {
AppendOtherTag("td", _beforeContent, _afterContent);
}
if (!IsAttributeDefined(HtmlTextWriterAttribute.Cellpadding)) {
AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
}
if (!IsAttributeDefined(HtmlTextWriterAttribute.Cellspacing)) {
AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
}
if (!IsStyleAttributeDefined(HtmlTextWriterStyle.BorderWidth)) {
AddAttribute(HtmlTextWriterAttribute.Border, "0");
}
if (!IsStyleAttributeDefined(HtmlTextWriterStyle.Width)) {
AddAttribute(HtmlTextWriterAttribute.Width, "100%");
}
}
}
base.RenderBeginTag(tagKey);
}
示例15: OnTagRender
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
protected override bool OnTagRender(string name, HtmlTextWriterTag key) {
// handle any tags that do not work downlevel
SetTagSupports();
if (Supports(FONT_PROPAGATE)) {
FontStack.Push(new FontStackItem());
}
// div->table substitution.
// Make tag look like a table. This must be done after we establish tag support.
if (key == HtmlTextWriterTag.Div && ShouldPerformDivTableSubstitution) {
TagKey = HtmlTextWriterTag.Table;
}
return base.OnTagRender(name,key);
}