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。