HtmlTextWriter.Indent Propriedade

Definição

Obtém ou define o número de posições de tabulação para indentar o início de cada linha de marcação.

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

Valor de Propriedade

O número de posições de abas a indentar cada linha.

Exemplos

O seguinte exemplo de código demonstra como incrementar o valor atribuído à Indent propriedade quando os atributos foram adicionados à etiqueta de abertura de um <span> elemento e o RenderBeginTag método foi chamado. Isto aumenta a indentação para qualquer marcação que seja renderizada dentro do <span> elemento.

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

Observações

A indentação é realizada escrevendo a cadeia especificada pelo tabString parâmetro do HtmlTextWriter(TextWriter, String) construtor o número de vezes especificadas pela Indent propriedade.

Se a Indent propriedade for definida para um valor negativo, é alterada para 0 antes de ser guardada.

Aplica-se a

Ver também