HtmlTextWriter.Indent Właściwość

Definicja

Pobiera lub ustawia liczbę pozycji tabulacji, aby wcięć początek każdej linii znaczników.

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

Wartość właściwości

Int32

Liczba pozycji tabulacji w celu wcięcia każdego wiersza.

Przykłady

W poniższym przykładzie kodu pokazano, jak zwiększać wartość przypisaną do Indent właściwości, gdy atrybuty zostały dodane do tagu otwierającego <span> elementu i RenderBeginTag metoda została wywołana. Zwiększa to wcięcie dla każdego znacznika renderowanego wewnątrz <span> elementu.

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

Uwagi

Wcięcie jest wykonywane przez zapisanie ciągu, który jest określony przez tabString parametr HtmlTextWriter(TextWriter, String) konstruktora liczbę razy, które są określone przez Indent właściwość.

Indent Jeśli właściwość jest ustawiona na wartość ujemną, zostanie zmieniona na 0 przed zapisaniem.

Dotyczy

Zobacz też