HtmlTextWriter.Indent 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置要缩进每行标记开头的制表位数。
public:
property int Indent { int get(); void set(int value); };
public int Indent { get; set; }
member this.Indent : int with get, set
Public Property Indent As Integer
属性值
要缩进每行的制表位数。
示例
下面的代码示例演示如何在将属性添加到元素的<span>开始标记和RenderBeginTag调用方法时递增分配给属性的值Indent。 这会增加元素内呈现的任何标记的 <span> 缩进。
// Set attributes and values along with attributes and styles
// attribute defined for a <span> element.
writer.AddAttribute(HtmlTextWriterAttribute.Onclick, "alert('Hello');");
writer.AddAttribute("CustomAttribute", "CustomAttributeValue");
writer.AddStyleAttribute(HtmlTextWriterStyle.Color, "Red");
writer.AddStyleAttribute("Customstyle", "CustomStyleValue");
writer.RenderBeginTag(HtmlTextWriterTag.Span);
// Create a space and indent the markup inside the
// <span> element.
writer.WriteLine();
writer.Indent++;
' Set attributes and values along with attributes and styles
' attribute defined for a <span> element.
writer.AddAttribute(HtmlTextWriterAttribute.Onclick, "alert('Hello');")
writer.AddAttribute("CustomAttribute", "CustomAttributeValue")
writer.AddStyleAttribute(HtmlTextWriterStyle.Color, "Red")
writer.AddStyleAttribute("CustomStyle", "CustomStyleValue")
writer.RenderBeginTag(HtmlTextWriterTag.Span)
' Create a space and indent the markup inside the
' <span> element.
writer.WriteLine()
writer.Indent += 1
注解
缩进是通过写入构造函数的参数HtmlTextWriter(TextWriter, String)指定的tabString字符串来执行的,该字符串由Indent属性指定的次数。
Indent如果该属性设置为负值,则会在保存之前将其更改为 0。