HtmlTextWriter.Indent HtmlTextWriter.Indent HtmlTextWriter.Indent HtmlTextWriter.Indent Property

定義

取得或設定定位點位置的數目,此為標記的每一行開頭要縮排的數目。Gets or sets the number of tab positions to indent the beginning of each line of markup.

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

屬性值

每一行要縮排的定位點位置的數目。The number of tab positions to indent each line.

範例

下列程式碼範例示範當屬性已加入至專案的開頭標記Indent <span> ,而且RenderBeginTag已呼叫方法時,如何遞增指派給屬性的值。The following code example demonstrates how to increment the value that is assigned to the Indent property when attributes have been added to the opening tag of a <span> element and the RenderBeginTag method has been called. 這會增加在<span>元素內呈現之任何標記的縮排。This increases the indentation for any markup that is rendered inside the <span> element.

// 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

備註

縮排的執行方式是將tabString Indent屬性所指定的次數,寫入由HtmlTextWriter(TextWriter, String)函式的參數所指定的字串。Indentation is performed by writing the string that is specified by the tabString parameter of the HtmlTextWriter(TextWriter, String) constructor the number of times that are specified by the Indent property.

Indent如果屬性設定為負值,則會在儲存之前將其變更為0。If the Indent property is set to a negative value, it is changed to 0 before being saved.

適用於

另請參閱