Udostępnij za pośrednictwem


HtmlTextWriter.Indent Właściwość

Definicja

Pobiera lub ustawia liczbę pozycji tabulacji w celu wcięcia początku 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

Liczba pozycji tabulacji do 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. Spowoduje to zwiększenie wcięcia 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 określonego HtmlTextWriter(TextWriter, String) przez tabString parametr konstruktora liczbę razy określoną przez Indent właściwość .

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

Dotyczy

Zobacz też