Partager via


HtmlTextWriter.Indent Propriété

Définition

Obtient ou définit le nombre de positions de tabulation à mettre en retrait le début de chaque ligne de balisage.

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é

Nombre de positions de tabulation à mettre en retrait 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 tout balisage rendu à 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 remplacée par 0 avant d’être enregistrée.

S’applique à

Voir aussi