HtmlTextWriter.Indent プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
マークアップの各行の先頭をインデントするタブ位置の数を取得または設定します。
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
プロパティ値
各行をインデントするタブ位置の数。
例
次のコード例では、<span>要素の開始タグに属性が追加され、RenderBeginTag メソッドが呼び出されたときに、Indent プロパティに割り当てられる値をインクリメントする方法を示します。 これにより、 <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
注釈
インデントは、HtmlTextWriter(TextWriter, String) コンストラクターのtabString パラメーターで指定された文字列を、Indent プロパティで指定された回数だけ書き込むことで実行されます。
Indent プロパティが負の値に設定されている場合は、保存する前に 0 に変更されます。