HtmlTextWriter.Indent Propriété

Définition

Obtient ou définit le nombre de tabulations du retrait à respecter au début d'une ligne HTML.

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

Valeur de propriété

Int32

Le nombre de tabulations pour la mise en retrait de chaque ligne.

Exemples

L’exemple de code suivant montre comment incrémenter la valeur affectée à la Indent propriété lorsque des attributs ont été ajoutés à la balise d’ouverture d’un <span> élément et que la RenderBeginTag méthode a été appelée. Cela augmente la mise en retrait pour toutes les marques affichées à l’intérieur de l’élément <span> .

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

Remarques

La mise en retrait est effectuée en écrivant la chaîne spécifiée par le tabString paramètre du HtmlTextWriter(TextWriter, String) constructeur le nombre de fois spécifiés par la Indent propriété.

Si la Indent propriété est définie sur une valeur négative, elle est modifiée à 0 avant d’être enregistrée.

S’applique à

Voir aussi