HtmlTextWriter.Indent 屬性

定義

取得或設定定位點位置的數目,此為標記的每一行開頭要縮排的數目。

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

屬性值

Int32

每一行要縮排的定位點位置的數目。

範例

下列程式碼範例示範如何將屬性新增至專案開頭標記 <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。

適用於

另請參閱