HtmlTextWriter.WriteBeginTag Method
Writes any tab spacing and the opening tag of the specified HTML element to the HtmlTextWriter output stream.
[Visual Basic] Public Overridable Sub WriteBeginTag( _ ByVal tagName As String _ ) [C#] public virtual void WriteBeginTag( string tagName ); [C++] public: virtual void WriteBeginTag( String* tagName ); [JScript] public function WriteBeginTag( tagName : String );
Parameters
- tagName
- The HTML element to write the opening tag of.
Remarks
This method does not write the closing character (>) of the HTML element's opening tag. This allows the writing of HTML attributes to the opening tag of the element. Use the TagRightChar constant to close the opening tag when calling this method. Use this method with the SelfClosingTagEnd constant when you write HTML elements that are self closing.
This method is used by custom server controls that do not allow tag or attribute mapping and render HTML elements in the same way for each request.
Example
[Visual Basic, C#, C++] The following example demonstrates using the WriteBeginTag method to create an Img element. The Write method is called with the TagRightChar constant as an argument to close the opening tag, after the attributes and their values are rendered.
[Visual Basic] ' Create a manually rendered tag. writer.WriteBeginTag("img") writer.WriteAttribute("alt", "AtlValue") writer.WriteAttribute("myattribute", "No "encoding " required", False) writer.Write(HtmlTextWriter.TagRightChar) writer.WriteEndTag("img") writer.WriteLine() writer.Indent -= 1 writer.RenderEndTag() [C#] // Create a manually rendered tag. writer.WriteBeginTag("img"); writer.WriteAttribute("alt", "AtlValue"); writer.WriteAttribute("myattribute", "No "encoding " required", false); writer.Write(HtmlTextWriter.TagRightChar); writer.WriteEndTag("img"); writer.WriteLine(); writer.Indent--; writer.RenderEndTag(); [C++] // Create a manually rendered tag. writer->WriteBeginTag(S"img"); writer->WriteAttribute(S"alt", S"AtlValue"); writer->WriteAttribute(S"myattribute", S"No "encoding " required", false); writer->Write(HtmlTextWriter::TagRightChar); writer->WriteEndTag(S"img"); writer->WriteLine(); writer->Indent--; writer->RenderEndTag();
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
See Also
HtmlTextWriter Class | HtmlTextWriter Members | System.Web.UI Namespace