HtmlTextWriter.RenderBeginTag Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Writes the opening tag of a markup element to the output stream.
Overloads
RenderBeginTag(String) |
Writes the opening tag of the specified markup element to the output stream. |
RenderBeginTag(HtmlTextWriterTag) |
Writes the opening tag of the markup element associated with the specified HtmlTextWriterTag enumeration value to the output stream. |
RenderBeginTag(String)
Writes the opening tag of the specified markup element to the output stream.
public:
virtual void RenderBeginTag(System::String ^ tagName);
public virtual void RenderBeginTag (string tagName);
abstract member RenderBeginTag : string -> unit
override this.RenderBeginTag : string -> unit
Public Overridable Sub RenderBeginTag (tagName As String)
Parameters
- tagName
- String
A string containing the name of the markup element for which to render the opening tag.
Examples
The following code example shows how to call the RenderBeginTag method in a custom control to render the opening tag of a non-standard MyTag
element. The code example then calls the Write method to render inner markup, and then calls the RenderEndTag method to close the element.
This code example generates the following markup:
<MyTag>
Contents of MyTag
</MyTag>
// Create a non-standard tag.
writer->RenderBeginTag( "MyTag" );
writer->Write( "Contents of MyTag" );
writer->RenderEndTag();
writer->WriteLine();
// Create a non-standard tag.
writer.RenderBeginTag("MyTag");
writer.Write("Contents of MyTag");
writer.RenderEndTag();
writer.WriteLine();
' Create a non-standard tag.
writer.RenderBeginTag("MyTag")
writer.Write("Contents of MyTag")
writer.RenderEndTag()
writer.WriteLine()
Remarks
Use the RenderBeginTag override of the RenderBeginTag(String) method, if the markup element is not one of the HtmlTextWriterTag enumeration values.
To generate a markup element by using the RenderBeginTag method, first call the AddAttribute and the AddStyleAttribute methods, as necessary, to specify any element attributes or style attributes that are to appear in the opening tag of the element. After generating the inner markup, call the RenderEndTag method to generate the closing tag.
See also
Applies to
RenderBeginTag(HtmlTextWriterTag)
Writes the opening tag of the markup element associated with the specified HtmlTextWriterTag enumeration value to the output stream.
public:
virtual void RenderBeginTag(System::Web::UI::HtmlTextWriterTag tagKey);
public virtual void RenderBeginTag (System.Web.UI.HtmlTextWriterTag tagKey);
abstract member RenderBeginTag : System.Web.UI.HtmlTextWriterTag -> unit
override this.RenderBeginTag : System.Web.UI.HtmlTextWriterTag -> unit
Public Overridable Sub RenderBeginTag (tagKey As HtmlTextWriterTag)
Parameters
- tagKey
- HtmlTextWriterTag
One of the HtmlTextWriterTag values that defines the opening tag of the markup element to render.
Examples
The following code example shows how to use the RenderBeginTag method to output the opening tag of an <img>
element. The attributes that are added to the element by the AddAttribute method will be in the opening <img>
tag. The RenderEndTag method is used to generate the closing tag.
This code example generates the following markup:
<img alt="Encoding "Required"" myattribute="No "encoding" required">
</img>
// Control the encoding of attributes.
// Simple known values do not need encoding.
writer->AddAttribute( HtmlTextWriterAttribute::Alt, "Encoding, \"Required\"", true );
writer->AddAttribute( "myattribute", "No "encoding " required", false );
writer->RenderBeginTag( HtmlTextWriterTag::Img );
writer->RenderEndTag();
writer->WriteLine();
// Control the encoding of attributes.
// Simple known values do not need encoding.
writer.AddAttribute(HtmlTextWriterAttribute.Alt, "Encoding, \"Required\"", true);
writer.AddAttribute("myattribute", "No "encoding " required", false);
writer.RenderBeginTag(HtmlTextWriterTag.Img);
writer.RenderEndTag();
writer.WriteLine();
' Control the encoding of attributes.
' Simple known values do not need encoding.
writer.AddAttribute(HtmlTextWriterAttribute.Alt, "Encoding, ""Required""", True)
writer.AddAttribute("myattribute", "No "encoding " required", False)
writer.RenderBeginTag(HtmlTextWriterTag.Img)
writer.RenderEndTag()
writer.WriteLine()
Remarks
Use the RenderBeginTag overload of the RenderBeginTag(HtmlTextWriterTag) method if the markup element is of a known type that is one of the HtmlTextWriterTag enumeration values.
To generate a markup element by using the RenderBeginTag method, first call the AddAttribute and the AddStyleAttribute methods, as necessary, to specify any element attributes or style attributes that are to appear in the opening tag of the element. After generating the inner markup, call the RenderEndTag method to generate the closing tag.
See also
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기