HtmlTextWriter.NewLine Propriedade
Definição
Obtém ou define a cadeia de caracteres de terminador de linha usada pelo objeto HtmlTextWriter.Gets or sets the line terminator string used by the HtmlTextWriter object.
public:
virtual property System::String ^ NewLine { System::String ^ get(); void set(System::String ^ value); };
public override string NewLine { get; set; }
member this.NewLine : string with get, set
Public Overrides Property NewLine As String
Valor da propriedade
A cadeia de caracteres de terminador de linha usada pelo HtmlTextWriter atual.The line terminator string used by the current HtmlTextWriter.
Exemplos
O exemplo de código a seguir mostra como usar uma classe personalizada, derivada da HtmlTextWriter classe, que substitui o FilterAttributes método.The following code example shows how to use a custom class, derived from the HtmlTextWriter class, that overrides the FilterAttributes method. Quando chamado, a FilterAttributes substituição verifica se o text writer renderiza qualquer <label> elemento ou <a> .When called, the FilterAttributes override checks whether the text writer renders any <label> or <a> elements. Nesse caso, o FilterAttributes método determina se um atributo de estilo é definido para o rótulo.If so, the FilterAttributes method determines whether a style attribute is defined for the label. Se nenhum estilo for definido, o FilterAttributes método definirá o valor padrão para o style:color atributo como azul.If no style is defined, the FilterAttributes method sets the default value for the style:color attribute to blue. FilterAttributesEm seguida, o método usa a NewLine propriedade para inserir uma quebra de linha na marca de marcação e grava quaisquer outros atributos definidos.The FilterAttributes method then uses the NewLine property to insert a line break in the markup tag and writes any other defined attributes.
// Override the FilterAttributes method to check whether
// <label> and <anchor> elements contain specific attributes.
virtual void FilterAttributes() override
{
// If the <label> element is rendered and a style
// attribute is not defined, add a style attribute
// and set its value to blue.
if ( TagKey == HtmlTextWriterTag::Label )
{
if ( !IsAttributeDefined( HtmlTextWriterAttribute::Style ) )
{
AddAttribute( "style", EncodeAttributeValue( "color:blue", true ) );
Write( NewLine );
Indent = 3;
OutputTabs();
}
}
// If an <anchor> element is rendered and an href
// attribute has not been defined, call the AddAttribute
// method to add an href attribute
// and set it to http://www.cohowinery.com.
// Use the EncodeUrl method to convert any spaces to %20.
if ( TagKey == HtmlTextWriterTag::A )
{
if ( !IsAttributeDefined( HtmlTextWriterAttribute::Href ) )
{
AddAttribute( "href", EncodeUrl( "http://www.cohowinery.com" ) );
}
}
// Call the FilterAttributes method of the base class.
__super::FilterAttributes();
}
// Override the FilterAttributes method to check whether
// <label> and <anchor> elements contain specific attributes.
protected override void FilterAttributes()
{
// If the <label> element is rendered and a style
// attribute is not defined, add a style attribute
// and set its value to blue.
if (TagKey == HtmlTextWriterTag.Label)
{
if (!IsAttributeDefined(HtmlTextWriterAttribute.Style))
{
AddAttribute("style", EncodeAttributeValue("color:blue", true));
Write(NewLine);
Indent = 3;
OutputTabs();
}
}
// If an <anchor> element is rendered and an href
// attribute has not been defined, call the AddAttribute
// method to add an href attribute
// and set it to http://www.cohowinery.com.
// Use the EncodeUrl method to convert any spaces to %20.
if (TagKey == HtmlTextWriterTag.A)
{
if (!IsAttributeDefined(HtmlTextWriterAttribute.Href))
{
AddAttribute("href", EncodeUrl("http://www.cohowinery.com"));
}
}
// Call the FilterAttributes method of the base class.
base.FilterAttributes();
}
' Override the FilterAttributes method to check whether
' <label> and <anchor> elements contain specific attributes.
Protected Overrides Sub FilterAttributes()
' If the <label> element is rendered and a style
' attribute is not defined, add a style attribute
' and set its value to blue.
If TagKey = HtmlTextWriterTag.Label Then
If Not IsAttributeDefined(HtmlTextWriterAttribute.Style) Then
AddAttribute("style", EncodeAttributeValue("color:blue", True))
Write(NewLine)
Indent = 3
OutputTabs()
End If
End If
' If an <anchor> element is rendered and an href
' attribute has not been defined, call the AddAttribute
' method to add an href attribute
' and set it to http://www.cohowinery.com.
' Use the EncodeUrl method to convert any spaces to %20.
If TagKey = HtmlTextWriterTag.A Then
If Not IsAttributeDefined(HtmlTextWriterAttribute.Href) Then
AddAttribute("href", EncodeUrl("http://www.cohowinery.com"))
End If
End If
' Call the FilterAttributes method of the base class.
MyBase.FilterAttributes()
End Sub
Comentários
A cadeia de caracteres de terminador de linha padrão é um retorno de carro, seguido por uma alimentação de linha ("\r\n").The default line terminator string is a carriage return, followed by a line feed ("\r\n").
A cadeia de caracteres de terminador de linha é gravada no fluxo de saída sempre que um dos WriteLine métodos é chamado.The line terminator string is written to the output stream whenever one of the WriteLine methods is called. Se a NewLine propriedade for definida como null , o caractere de nova linha padrão será usado.If the NewLine property is set to null, the default new line character is used.