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.Gets or sets the number of tab positions to indent the beginning of each line of 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

Valor da propriedade

Int32

O número de posições de tabulação para recuar cada linha.The number of tab positions to indent each line.

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 método foi RenderBeginTag chamado.The following code example demonstrates how to increment the value that is assigned to the Indent property when attributes have been added to the opening tag of a <span> element and the RenderBeginTag method has been called. Isso aumenta o recuo para qualquer marcação que é processada dentro do <span> elemento.This increases the indentation for any markup that is rendered inside the <span> element.

// 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-se a cadeia de caracteres especificada pelo tabString parâmetro do HtmlTextWriter(TextWriter, String) Construtor o número de vezes especificado pela Indent propriedade.Indentation is performed by writing the string that is specified by the tabString parameter of the HtmlTextWriter(TextWriter, String) constructor the number of times that are specified by the Indent property.

Se a Indent propriedade for definida como um valor negativo, ela será alterada para 0 antes de ser salva.If the Indent property is set to a negative value, it is changed to 0 before being saved.

Aplica-se a

Confira também