HtmlTextWriter.WriteEndTag(String) HtmlTextWriter.WriteEndTag(String) HtmlTextWriter.WriteEndTag(String) HtmlTextWriter.WriteEndTag(String) Method

定義

寫入指定標記項目的任何定位空格和結尾標記。Writes any tab spacing and the closing tag of the specified markup element.

public:
 virtual void WriteEndTag(System::String ^ tagName);
public virtual void WriteEndTag (string tagName);
abstract member WriteEndTag : string -> unit
override this.WriteEndTag : string -> unit
Public Overridable Sub WriteEndTag (tagName As String)

參數

tagName
String String String String

寫入其結尾標記的項目。The element to write the closing tag for.

範例

下列程式碼範例示範如何呈現<img>元素。The following code example demonstrates rendering an <img> element. 此程式碼範例會使用下列進程:The code example uses the following process:

  • WriteBeginTag呼叫方法以轉譯元素的開頭字元。Calls the WriteBeginTag method to render the opening characters of the element.

  • 呼叫WriteAttribute方法的兩個多載,將屬性<img>寫入元素。Calls the two overloads of the WriteAttribute method to write attributes to the <img> element.

  • 呼叫方法以關閉<img>元素。 WriteEndTagCalls the WriteEndTag method to close the <img> element.

// Create a manually rendered tag.
writer->WriteBeginTag( "img" );
writer->WriteAttribute( "alt", "AtlValue" );
writer->WriteAttribute( "myattribute", "No &quot;encoding &quot; required", false );
writer->Write( HtmlTextWriter::TagRightChar );
writer->WriteEndTag( "img" );
// Create a manually rendered tag.
writer.WriteBeginTag("img");
writer.WriteAttribute("alt", "AtlValue");
writer.WriteAttribute("myattribute", "No &quot;encoding &quot; required", false);
writer.Write(HtmlTextWriter.TagRightChar);
writer.WriteEndTag("img");
' Create a manually rendered tag.
writer.WriteBeginTag("img")
writer.WriteAttribute("alt", "AtlValue")
writer.WriteAttribute("myattribute", "No &quot;encoding &quot; required", False)
writer.Write(HtmlTextWriter.TagRightChar)

備註

與方法不同的是WriteEndTag ,方法沒有任何邏輯可以讓元素結束標記符合對應的開頭標記。 RenderEndTagUnlike the RenderEndTag method, the WriteEndTag method has no logic to make the element end tag match the corresponding opening tag.

適用於

另請參閱