HtmlTextWriter Class
TOC
Collapse the table of content
Expand the table of content

HtmlTextWriter Class

 

Writes markup characters and text to an ASP.NET server control output stream. This class provides formatting capabilities that ASP.NET server controls use when rendering markup to clients.

Namespace:   System.Web.UI
Assembly:  System.Web (in System.Web.dll)

System.Object
  System.MarshalByRefObject
    System.IO.TextWriter
      System.Web.UI.HtmlTextWriter
        System.Web.UI.Html32TextWriter
        System.Web.UI.MobileControls.Adapters.MultiPartWriter
        System.Web.UI.XhtmlTextWriter

public class HtmlTextWriter : TextWriter

NameDescription
System_CAPS_pubmethodHtmlTextWriter(TextWriter)

Initializes a new instance of the HtmlTextWriter class that uses a default tab string.

System_CAPS_pubmethodHtmlTextWriter(TextWriter, String)

Initializes a new instance of the HtmlTextWriter class with a specified tab string character.

NameDescription
System_CAPS_pubpropertyEncoding

Gets the encoding that the HtmlTextWriter object uses to write content to the page.(Overrides TextWriter.Encoding.)

System_CAPS_pubpropertyFormatProvider

Gets an object that controls formatting.(Inherited from TextWriter.)

System_CAPS_pubpropertyIndent

Gets or sets the number of tab positions to indent the beginning of each line of markup.

System_CAPS_pubpropertyInnerWriter

Gets or sets the text writer that writes the inner content of the markup element.

System_CAPS_pubpropertyNewLine

Gets or sets the line terminator string used by the HtmlTextWriter object.(Overrides TextWriter.NewLine.)

System_CAPS_protpropertyTagKey

Gets or sets the HtmlTextWriterTag value for the specified markup element.

System_CAPS_protpropertyTagName

Gets or sets the tag name of the markup element being rendered.

NameDescription
System_CAPS_pubmethodAddAttribute(HtmlTextWriterAttribute, String)

Adds the markup attribute and the attribute value to the opening tag of the element that the HtmlTextWriter object creates with a subsequent call to the RenderBeginTag method.

System_CAPS_pubmethodAddAttribute(HtmlTextWriterAttribute, String, Boolean)

Adds the markup attribute and the attribute value to the opening tag of the element that the HtmlTextWriter object creates with a subsequent call to the RenderBeginTag method, with optional encoding.

System_CAPS_pubmethodAddAttribute(String, String)

Adds the specified markup attribute and value to the opening tag of the element that the HtmlTextWriter object creates with a subsequent call to the RenderBeginTag method.

System_CAPS_pubmethodAddAttribute(String, String, Boolean)

Adds the specified markup attribute and value to the opening tag of the element that the HtmlTextWriter object creates with a subsequent call to the RenderBeginTag method, with optional encoding.

System_CAPS_protmethodAddAttribute(String, String, HtmlTextWriterAttribute)

Adds the specified markup attribute and value, along with an HtmlTextWriterAttribute enumeration value, to the opening tag of the element that the HtmlTextWriter object creates with a subsequent call to the RenderBeginTag method.

System_CAPS_pubmethodAddStyleAttribute(HtmlTextWriterStyle, String)

Adds the markup style attribute associated with the specified HtmlTextWriterStyle value and the attribute value to the opening markup tag created by a subsequent call to the RenderBeginTag method.

System_CAPS_pubmethodAddStyleAttribute(String, String)

Adds the specified markup style attribute and the attribute value to the opening markup tag created by a subsequent call to the RenderBeginTag method.

System_CAPS_protmethodAddStyleAttribute(String, String, HtmlTextWriterStyle)

Adds the specified markup style attribute and the attribute value, along with an HtmlTextWriterStyle enumeration value, to the opening markup tag created by a subsequent call to the RenderBeginTag method.

System_CAPS_pubmethodBeginRender()

Notifies an HtmlTextWriter object, or an object of a derived class, that a control is about to be rendered.

System_CAPS_pubmethodClose()

Closes the HtmlTextWriter object and releases any system resources associated with it.(Overrides TextWriter.Close().)

System_CAPS_pubmethodCreateObjRef(Type)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodDispose()

Releases all resources used by the TextWriter object.(Inherited from TextWriter.)

System_CAPS_protmethodDispose(Boolean)

Releases the unmanaged resources used by the TextWriter and optionally releases the managed resources.(Inherited from TextWriter.)

System_CAPS_protmethodEncodeAttributeValue(HtmlTextWriterAttribute, String)

Encodes the value of the specified markup attribute based on the requirements of the HttpRequest object of the current context.

System_CAPS_protmethodEncodeAttributeValue(String, Boolean)

Encodes the value of the specified markup attribute based on the requirements of the HttpRequest object of the current context.

System_CAPS_protmethodEncodeUrl(String)

Performs minimal URL encoding by converting spaces in the specified URL to the string "%20".

System_CAPS_pubmethodEndRender()

Notifies an HtmlTextWriter object, or an object of a derived class, that a control has finished rendering. You can use this method to close any markup elements opened in the BeginRender method.

System_CAPS_pubmethodEnterStyle(Style)

Writes the opening tag of a <span> element that contains attributes that implement the layout and character formatting of the specified style.

System_CAPS_pubmethodEnterStyle(Style, HtmlTextWriterTag)

Writes the opening tag of a markup element that contains attributes that implement the layout and character formatting of the specified style.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodExitStyle(Style)

Writes the closing tag of a <span> element to end the specified layout and character formatting.

System_CAPS_pubmethodExitStyle(Style, HtmlTextWriterTag)

Writes the closing tag of the specified markup element to end the specified layout and character formatting.

System_CAPS_protmethodFilterAttributes()

Removes all the markup and style attributes on all properties of the page or Web server control.

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodFlush()

Clears all buffers for the current HtmlTextWriter object and causes any buffered data to be written to the output stream.(Overrides TextWriter.Flush().)

System_CAPS_pubmethodFlushAsync()

Asynchronously clears all buffers for the current writer and causes any buffered data to be written to the underlying device. (Inherited from TextWriter.)

System_CAPS_protmethodGetAttributeKey(String)

Obtains the corresponding HtmlTextWriterAttribute enumeration value for the specified attribute.

System_CAPS_protmethodGetAttributeName(HtmlTextWriterAttribute)

Obtains the name of the markup attribute associated with the specified HtmlTextWriterAttribute value.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_protmethodGetStyleKey(String)

Obtains the HtmlTextWriterStyle enumeration value for the specified style.

System_CAPS_protmethodGetStyleName(HtmlTextWriterStyle)

Obtains the markup style attribute name associated with the specified HtmlTextWriterStyle enumeration value.

System_CAPS_protmethodGetTagKey(String)

Obtains the HtmlTextWriterTag enumeration value associated with the specified markup element.

System_CAPS_protmethodGetTagName(HtmlTextWriterTag)

Obtains the markup element associated with the specified HtmlTextWriterTag enumeration value.

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodInitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_protmethodIsAttributeDefined(HtmlTextWriterAttribute)

Determines whether the specified markup attribute and its value are rendered during the next call to the RenderBeginTag method.

System_CAPS_protmethodIsAttributeDefined(HtmlTextWriterAttribute, String)

Determines whether the specified markup attribute and its value are rendered during the next call to the RenderBeginTag method.

System_CAPS_protmethodIsStyleAttributeDefined(HtmlTextWriterStyle)

Determines whether the specified markup style attribute is rendered during the next call to the RenderBeginTag method.

System_CAPS_protmethodIsStyleAttributeDefined(HtmlTextWriterStyle, String)

Determines whether the specified markup style attribute and its value are rendered during the next call to the RenderBeginTag method.

System_CAPS_pubmethodIsValidFormAttribute(String)

Checks an attribute to ensure that it can be rendered in the opening tag of a <form> markup element.

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.(Inherited from MarshalByRefObject.)

System_CAPS_protmethodOnAttributeRender(String, String, HtmlTextWriterAttribute)

Determines whether the specified markup attribute and its value can be rendered to the current markup element.

System_CAPS_protmethodOnStyleAttributeRender(String, String, HtmlTextWriterStyle)

Determines whether the specified markup style attribute and its value can be rendered to the current markup element.

System_CAPS_protmethodOnTagRender(String, HtmlTextWriterTag)

Determines whether the specified markup element will be rendered to the requesting page.

System_CAPS_protmethodOutputTabs()

Writes a series of tab strings that represent the indentation level for a line of markup characters.

System_CAPS_protmethodPopEndTag()

Removes the most recently saved markup element from the list of rendered elements.

System_CAPS_protmethodPushEndTag(String)

Saves the specified markup element for later use when generating the end tag for a markup element.

System_CAPS_protmethodSystem_CAPS_staticRegisterAttribute(String, HtmlTextWriterAttribute)

Registers markup attributes, whether literals or dynamically generated, from the source file so that they can be properly rendered to the requesting client.

System_CAPS_protmethodSystem_CAPS_staticRegisterStyle(String, HtmlTextWriterStyle)

Registers markup style properties, whether literals or dynamically generated, from the source file so that they can be properly rendered to the requesting client.

System_CAPS_protmethodSystem_CAPS_staticRegisterTag(String, HtmlTextWriterTag)

Registers markup tags, whether literals or dynamically generated, from the source file so that they can be properly rendered to the requesting client.

System_CAPS_protmethodRenderAfterContent()

Writes any text or spacing that occurs after the content and before the closing tag of the markup element to the markup output stream.

System_CAPS_protmethodRenderAfterTag()

Writes any spacing or text that occurs after the closing tag for a markup element.

System_CAPS_protmethodRenderBeforeContent()

Writes any text or spacing before the content and after the opening tag of a markup element.

System_CAPS_protmethodRenderBeforeTag()

Writes any text or spacing that occurs before the opening tag of a markup element.

System_CAPS_pubmethodRenderBeginTag(HtmlTextWriterTag)

Writes the opening tag of the markup element associated with the specified HtmlTextWriterTag enumeration value to the output stream.

System_CAPS_pubmethodRenderBeginTag(String)

Writes the opening tag of the specified markup element to the output stream.

System_CAPS_pubmethodRenderEndTag()

Writes the end tag of a markup element to the output stream.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_pubmethodWrite(Boolean)

Writes the text representation of a Boolean value to the output stream, along with any pending tab spacing.(Overrides TextWriter.Write(Boolean).)

System_CAPS_pubmethodWrite(Char)

Writes the text representation of a Unicode character to the output stream, along with any pending tab spacing.(Overrides TextWriter.Write(Char).)

System_CAPS_pubmethodWrite(Char[])

Writes the text representation of an array of Unicode characters to the output stream, along with any pending tab spacing.(Overrides TextWriter.Write(Char[]).)

System_CAPS_pubmethodWrite(Char[], Int32, Int32)

Writes the text representation of a subarray of Unicode characters to the output stream, along with any pending tab spacing.(Overrides TextWriter.Write(Char[], Int32, Int32).)

System_CAPS_pubmethodWrite(Decimal)

Writes the text representation of a decimal value to the text string or stream.(Inherited from TextWriter.)

System_CAPS_pubmethodWrite(Double)

Writes the text representation of a double-precision floating-point number to the output stream, along with any pending tab spacing.(Overrides TextWriter.Write(Double).)

System_CAPS_pubmethodWrite(Int32)

Writes the text representation of a 32-byte signed integer to the output stream, along with any pending tab spacing.(Overrides TextWriter.Write(Int32).)

System_CAPS_pubmethodWrite(Int64)

Writes the text representation of a 64-byte signed integer to the output stream, along with any pending tab spacing.(Overrides TextWriter.Write(Int64).)

System_CAPS_pubmethodWrite(Object)

Writes the text representation of an object to the output stream, along with any pending tab spacing.(Overrides TextWriter.Write(Object).)

System_CAPS_pubmethodWrite(Single)

Writes the text representation of a single-precision floating-point number to the output stream, along with any pending tab spacing.(Overrides TextWriter.Write(Single).)

System_CAPS_pubmethodWrite(String)

Writes the specified string to the output stream, along with any pending tab spacing.(Overrides TextWriter.Write(String).)

System_CAPS_pubmethodWrite(String, Object)

Writes a tab string and a formatted string to the output stream, using the same semantics as the String.Format method, along with any pending tab spacing.(Overrides TextWriter.Write(String, Object).)

System_CAPS_pubmethodWrite(String, Object, Object)

Writes a formatted string that contains the text representation of two objects to the output stream, along with any pending tab spacing. This method uses the same semantics as the String.Format method.(Overrides TextWriter.Write(String, Object, Object).)

System_CAPS_pubmethodWrite(String, Object, Object, Object)

Writes a formatted string to the text string or stream, using the same semantics as the String.Format(String, Object, Object, Object) method.(Inherited from TextWriter.)

System_CAPS_pubmethodWrite(String, Object[])

Writes a formatted string that contains the text representation of an object array to the output stream, along with any pending tab spacing. This method uses the same semantics as the String.Format method.(Overrides TextWriter.Write(String, Object[]).)

System_CAPS_pubmethodWrite(UInt32)

Writes the text representation of a 4-byte unsigned integer to the text string or stream.(Inherited from TextWriter.)

System_CAPS_pubmethodWrite(UInt64)

Writes the text representation of an 8-byte unsigned integer to the text string or stream.(Inherited from TextWriter.)

System_CAPS_pubmethodWriteAsync(Char)

Writes a character to the text string or stream asynchronously.(Inherited from TextWriter.)

System_CAPS_pubmethodWriteAsync(Char[])

Writes a character array to the text string or stream asynchronously.(Inherited from TextWriter.)

System_CAPS_pubmethodWriteAsync(Char[], Int32, Int32)

Writes a subarray of characters to the text string or stream asynchronously. (Inherited from TextWriter.)

System_CAPS_pubmethodWriteAsync(String)

Writes a string to the text string or stream asynchronously.(Inherited from TextWriter.)

System_CAPS_pubmethodWriteAttribute(String, String)

Writes the specified markup attribute and value to the output stream.

System_CAPS_pubmethodWriteAttribute(String, String, Boolean)

Writes the specified markup attribute and value to the output stream, and, if specified, writes the value encoded.

System_CAPS_pubmethodWriteBeginTag(String)

Writes any tab spacing and the opening tag of the specified markup element to the output stream.

System_CAPS_pubmethodWriteBreak()

Writes a <br /> markup element to the output stream.

System_CAPS_pubmethodWriteEncodedText(String)

Encodes the specified text for the requesting device, and then writes it to the output stream.

System_CAPS_pubmethodWriteEncodedUrl(String)

Encodes the specified URL, and then writes it to the output stream. The URL might include parameters.

System_CAPS_pubmethodWriteEncodedUrlParameter(String)

Encodes the specified URL parameter for the requesting device, and then writes it to the output stream.

System_CAPS_pubmethodWriteEndTag(String)

Writes any tab spacing and the closing tag of the specified markup element.

System_CAPS_pubmethodWriteFullBeginTag(String)

Writes any tab spacing and the opening tag of the specified markup element to the output stream.

System_CAPS_pubmethodWriteLine()

Writes a line terminator string to the output stream.(Overrides TextWriter.WriteLine().)

System_CAPS_pubmethodWriteLine(Boolean)

Writes any pending tab spacing and the text representation of a Boolean value, followed by a line terminator string, to the output stream.(Overrides TextWriter.WriteLine(Boolean).)

System_CAPS_pubmethodWriteLine(Char)

Writes any pending tab spacing and a Unicode character, followed by a line terminator string, to the output stream.(Overrides TextWriter.WriteLine(Char).)

System_CAPS_pubmethodWriteLine(Char[])

Writes any pending tab spacing and an array of Unicode characters, followed by a line terminator string, to the output stream.(Overrides TextWriter.WriteLine(Char[]).)

System_CAPS_pubmethodWriteLine(Char[], Int32, Int32)

Writes any pending tab spacing and a subarray of Unicode characters, followed by a line terminator string, to the output stream.(Overrides TextWriter.WriteLine(Char[], Int32, Int32).)

System_CAPS_pubmethodWriteLine(Decimal)

Writes the text representation of a decimal value followed by a line terminator to the text string or stream.(Inherited from TextWriter.)

System_CAPS_pubmethodWriteLine(Double)

Writes any pending tab spacing and the text representation of a double-precision floating-point number, followed by a line terminator string, to the output stream.(Overrides TextWriter.WriteLine(Double).)

System_CAPS_pubmethodWriteLine(Int32)

Writes any pending tab spacing and the text representation of a 32-byte signed integer, followed by a line terminator string, to the output stream.(Overrides TextWriter.WriteLine(Int32).)

System_CAPS_pubmethodWriteLine(Int64)

Writes any pending tab spacing and the text representation of a 64-byte signed integer, followed by a line terminator string, to the output stream.(Overrides TextWriter.WriteLine(Int64).)

System_CAPS_pubmethodWriteLine(Object)

Writes any pending tab spacing and the text representation of an object, followed by a line terminator string, to the output stream.(Overrides TextWriter.WriteLine(Object).)

System_CAPS_pubmethodWriteLine(Single)

Writes any pending tab spacing and the text representation of a single-precision floating-point number, followed by a line terminator string, to the output stream.(Overrides TextWriter.WriteLine(Single).)

System_CAPS_pubmethodWriteLine(String)

Writes any pending tab spacing and a text string, followed by a line terminator string, to the output stream.(Overrides TextWriter.WriteLine(String).)

System_CAPS_pubmethodWriteLine(String, Object)

Writes any pending tab spacing and a formatted string containing the text representation of an object, followed by a line terminator string, to the output stream. (Overrides TextWriter.WriteLine(String, Object).)

System_CAPS_pubmethodWriteLine(String, Object, Object)

Writes any pending tab spacing and a formatted string that contains the text representation of two objects, followed by a line terminator string, to the output stream.(Overrides TextWriter.WriteLine(String, Object, Object).)

System_CAPS_pubmethodWriteLine(String, Object, Object, Object)

Writes out a formatted string and a new line, using the same semantics as Format.(Inherited from TextWriter.)

System_CAPS_pubmethodWriteLine(String, Object[])

Writes any pending tab spacing and a formatted string that contains the text representation of an object array, followed by a line terminator string, to the output stream.(Overrides TextWriter.WriteLine(String, Object[]).)

System_CAPS_pubmethodWriteLine(UInt32)

Writes any pending tab spacing and the text representation of a 4-byte unsigned integer, followed by a line terminator string, to the output stream.(Overrides TextWriter.WriteLine(UInt32).)

System_CAPS_pubmethodWriteLine(UInt64)

Writes the text representation of an 8-byte unsigned integer followed by a line terminator to the text string or stream.(Inherited from TextWriter.)

System_CAPS_pubmethodWriteLineAsync()

Writes a line terminator asynchronously to the text string or stream.(Inherited from TextWriter.)

System_CAPS_pubmethodWriteLineAsync(Char)

Writes a character followed by a line terminator asynchronously to the text string or stream.(Inherited from TextWriter.)

System_CAPS_pubmethodWriteLineAsync(Char[])

Writes an array of characters followed by a line terminator asynchronously to the text string or stream.(Inherited from TextWriter.)

System_CAPS_pubmethodWriteLineAsync(Char[], Int32, Int32)

Writes a subarray of characters followed by a line terminator asynchronously to the text string or stream.(Inherited from TextWriter.)

System_CAPS_pubmethodWriteLineAsync(String)

Writes a string followed by a line terminator asynchronously to the text string or stream. (Inherited from TextWriter.)

System_CAPS_pubmethodWriteLineNoTabs(String)

Writes a string, followed by a line terminator string, to the output stream. This method ignores any specified tab spacing.

System_CAPS_pubmethodWriteStyleAttribute(String, String)

Writes the specified style attribute to the output stream.

System_CAPS_pubmethodWriteStyleAttribute(String, String, Boolean)

Writes the specified style attribute and value to the output stream, and encodes the value, if specified.

System_CAPS_protmethodWriteUrlEncodedString(String, Boolean)

Writes the specified string, encoding it according to URL requirements.

NameDescription
System_CAPS_protfieldCoreNewLine

Stores the newline characters used for this TextWriter.(Inherited from TextWriter.)

System_CAPS_pubfieldSystem_CAPS_staticDefaultTabString

Represents a single tab character.

System_CAPS_pubfieldSystem_CAPS_staticDoubleQuoteChar

Represents the quotation mark (") character.

System_CAPS_pubfieldSystem_CAPS_staticEndTagLeftChars

Represents the left angle bracket and slash mark (</) of the closing tag of a markup element.

System_CAPS_pubfieldSystem_CAPS_staticEqualsChar

Represents the equal sign (=).

System_CAPS_pubfieldSystem_CAPS_staticEqualsDoubleQuoteString

Represents an equal sign (=) and a double quotation mark (") together in a string (=").

System_CAPS_pubfieldSystem_CAPS_staticSelfClosingChars

Represents a space and the self-closing slash mark (/) of a markup tag.

System_CAPS_pubfieldSystem_CAPS_staticSelfClosingTagEnd

Represents the closing slash mark and right angle bracket (/>) of a self-closing markup element.

System_CAPS_pubfieldSystem_CAPS_staticSemicolonChar

Represents the semicolon (;).

System_CAPS_pubfieldSystem_CAPS_staticSingleQuoteChar

Represents an apostrophe (').

System_CAPS_pubfieldSystem_CAPS_staticSlashChar

Represents the slash mark (/).

System_CAPS_pubfieldSystem_CAPS_staticSpaceChar

Represents a space ( ) character.

System_CAPS_pubfieldSystem_CAPS_staticStyleEqualsChar

Represents the style equals (:) character used to set style attributes equal to values.

System_CAPS_pubfieldSystem_CAPS_staticTagLeftChar

Represents the opening angle bracket (<) of a markup tag.

System_CAPS_pubfieldSystem_CAPS_staticTagRightChar

Represents the closing angle bracket (>) of a markup tag.

The HtmlTextWriter class is used to render HTML 4.0 to desktop browsers. The HtmlTextWriter is also the base class for all markup writers in the System.Web.UI namespace, including the ChtmlTextWriter, Html32TextWriter, and XhtmlTextWriter classes. These classes are used to write the elements, attributes, and style and layout information for different types of markup. In addition, these classes are used by the page and control adapter classes that are associated with each markup language.

In most circumstances, ASP.NET automatically uses the appropriate writer for the requesting device. However, if you create a custom text writer or if you want to specify a particular writer to render a page for a specific device, you must map the writer to the page in the controlAdapters section of the application .browser file.

The following code example shows how to override the Render method of a custom control that is derived from the Control class. The code example illustrates how to use various HtmlTextWriter methods, properties, and fields.

// Overrides the Render method to write a <span> element
// that applies styles and attributes. 
protected override void Render(HtmlTextWriter writer) 
{     
    // 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++;
    writer.Write("Hello");
    writer.WriteLine();

    // Controls the encoding of markup attributes
    // for an <img> element. Simple known values 
 // do not need encoding.
    writer.AddAttribute(HtmlTextWriterAttribute.Alt, 
        "Encoding, \"Required\"", 
        true);
    writer.AddAttribute("myattribute", 
        "No &quot;encoding &quot; required", 
        false);
    writer.RenderBeginTag(HtmlTextWriterTag.Img);
    writer.RenderEndTag();
    writer.WriteLine();

    // Create a non-standard markup element.
    writer.RenderBeginTag("MyTag");
    writer.Write("Contents of MyTag");
    writer.RenderEndTag();
    writer.WriteLine();

    // Create a manually rendered <img> element
    // that contains an alt attribute.
    writer.WriteBeginTag("img");
    writer.WriteAttribute("alt", "A custom image.");
    writer.Write(HtmlTextWriter.TagRightChar);
    writer.WriteEndTag("img");
    writer.WriteLine();

    writer.Indent--;
    writer.RenderEndTag();

}

.NET Framework
Available since 1.1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft