Bagikan melalui


HtmlTextWriter.Indent Properti

Definisi

Mendapatkan atau mengatur jumlah posisi tab untuk mengindentasi awal setiap baris 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

Nilai Properti

Jumlah posisi tab untuk mengindentasi setiap baris.

Contoh

Contoh kode berikut menunjukkan cara menambah nilai yang ditetapkan ke Indent properti ketika atribut telah ditambahkan ke tag pembuka elemen <span> dan RenderBeginTag metode telah dipanggil. Ini meningkatkan indentasi untuk markup apa pun yang dirender di <span> dalam elemen .

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

Keterangan

Indentasi dilakukan dengan menulis string yang ditentukan oleh tabString parameter HtmlTextWriter(TextWriter, String) konstruktor berapa kali ditentukan oleh Indent properti.

Indent Jika properti diatur ke nilai negatif, properti diubah menjadi 0 sebelum disimpan.

Berlaku untuk

Lihat juga