This documentation is archived and is not being maintained.

HtmlTextWriter.Indent Property

Gets or sets the number of spaces to indent at the beginning of a line of HTML.

[Visual Basic]
Public Property Indent As Integer
[C#]
public int Indent {get; set;}
[C++]
public: __property int get_Indent();
public: __property void set_Indent(int);
[JScript]
public function get Indent() : int;
public function set Indent(int);

Property Value

The number of spaces to indent.

Example

[Visual Basic, C#, C++] The following example demonstrates decrementing the value assigned to the Indent property once an Img element and its attributes have been written. This allows the indentation for the next HTML element to be rendered with less indentation than the Img element rendered by this code.

[Visual Basic] 
' Create a manually rendered tag.
writer.WriteBeginTag("img")
writer.WriteAttribute("alt", "AtlValue")
writer.WriteAttribute("myattribute", "No "encoding " required", False)
writer.Write(HtmlTextWriter.TagRightChar)
writer.WriteEndTag("img")
writer.WriteLine()

writer.Indent -= 1
writer.RenderEndTag()

[C#] 
// Create a manually rendered tag.
writer.WriteBeginTag("img");
writer.WriteAttribute("alt", "AtlValue");
writer.WriteAttribute("myattribute", "No "encoding " required", false);
writer.Write(HtmlTextWriter.TagRightChar);
writer.WriteEndTag("img");
writer.WriteLine();

writer.Indent--;
writer.RenderEndTag();

[C++] 
// Create a manually rendered tag.
writer->WriteBeginTag(S"img");
writer->WriteAttribute(S"alt", S"AtlValue");
writer->WriteAttribute(S"myattribute", S"No "encoding " required", false);
writer->Write(HtmlTextWriter::TagRightChar);
writer->WriteEndTag(S"img");
writer->WriteLine();

writer->Indent--;
writer->RenderEndTag();

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

HtmlTextWriter Class | HtmlTextWriter Members | System.Web.UI Namespace | OutputTabs

Show: