HtmlTextWriter.Indent 속성

정의

각 태그 줄의 시작 부분에서 들여쓰기할 탭 위치 수를 가져오거나 설정합니다.

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

속성 값

Int32

각 줄을 들여쓰기할 탭 위치 수입니다.

예제

다음 코드 예제에서는 특성이 요소 RenderBeginTag<span> 여는 태그에 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

설명

들여쓰기는 속성에 의해 tabString 지정된 횟수만큼 생성자의 매개 변수 HtmlTextWriter(TextWriter, String) 에 지정된 문자열을 Indent 작성하여 수행됩니다.

속성이 음수 Indent 값으로 설정된 경우 저장되기 전에 0으로 변경됩니다.

적용 대상

추가 정보