Condividi tramite


HtmlTextWriter.Indent Proprietà

Definizione

Ottiene o imposta il numero di posizioni di tabulazioni da impostare come rientro all'inizio di ogni riga di 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

Valore della proprietà

Numero di posizioni di tabulazioni da impostare come rientro per ogni riga.

Esempio

Nell'esempio di codice seguente viene illustrato come incrementare il valore assegnato alla Indent proprietà quando gli attributi sono stati aggiunti al tag di apertura di un <span> elemento e viene chiamato il RenderBeginTag metodo . In questo modo si aumenta il rientro per qualsiasi markup di cui viene eseguito il rendering all'interno dell'elemento <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

Commenti

Il rientro viene eseguito scrivendo la stringa specificata dal tabString parametro del HtmlTextWriter(TextWriter, String) costruttore il numero di volte specificato dalla Indent proprietà .

Se la Indent proprietà è impostata su un valore negativo, viene modificata in 0 prima di essere salvata.

Si applica a

Vedi anche