HtmlTextWriter.Indent Propriedade

Definição

Obtém ou define o número de posições de tabulação para recuar 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 da propriedade

Int32

O número de posições de guia para recuar cada linha.

Exemplos

O exemplo de código a seguir demonstra como incrementar o valor atribuído à Indent propriedade quando atributos foram adicionados à marca de abertura de um <span> elemento e o RenderBeginTag método foi chamado. Isso aumenta o recuo para qualquer marcação 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

Comentários

O recuo é executado escrevendo a cadeia de caracteres especificada pelo tabString parâmetro do HtmlTextWriter(TextWriter, String) construtor o número de vezes especificado pela Indent propriedade.

Se a Indent propriedade for definida como um valor negativo, ela será alterada para 0 antes de ser salva.

Aplica-se a

Confira também