Sdílet prostřednictvím


HtmlTextWriter.Indent Vlastnost

Definice

Získá nebo nastaví počet pozic tabulátoru, které odsadí začátek každého řádku značek.

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

Hodnota vlastnosti

Počet pozic tabulátoru pro odsazení jednotlivých řádků.

Příklady

Následující příklad kódu ukazuje, jak zvýšit hodnotu, která je přiřazena vlastnosti Indent , když atributy byly přidány do počáteční značky <span> elementu a RenderBeginTag metoda byla volána. Tím se zvětšuje odsazení všech revizí, které se vykreslují uvnitř elementu <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

Poznámky

Odsazení se provádí zápisem řetězce určeného HtmlTextWriter(TextWriter, String) parametrem tabString konstruktoru, kolikrát je vlastnost určenaIndent.

Indent Pokud je vlastnost nastavena na zápornou hodnotu, před uložením se změní na 0.

Platí pro

Viz také