HtmlTextWriter.NewLine プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > HtmlTextWriter.NewLine プロパティの意味・解説 

HtmlTextWriter.NewLine プロパティ

HtmlTextWriter オブジェクト使用される終端文字列取得または設定します

名前空間: System.Web.UI
アセンブリ: System.Web (system.web.dll 内)
構文構文

解説解説
使用例使用例

FilterAttributes メソッドオーバーライドする HtmlTextWriter クラスから派生したカスタム クラス使用する方法次のコード例示しますFilterAttributes オーバーライド呼び出されると、テキスト ライタによって <label> 要素または <a> 要素出力されるかどうかチェックされます。出力される場合FilterAttributes メソッドによって、ラベルスタイル属性定義されているかどうかチェックされます。スタイル定義されていない場合は、FilterAttributes メソッドによって、style:color 属性既定値blue設定されます。次にFilterAttributes メソッドNewLine プロパティ使用してマークアップ タグ改行挿入しその他の定義済み属性出力します

' 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
// 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.
 
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 void FilterAttributes()
{
    // If the Label tag is being rendered and a style
    // attribute is not defined, add a style attribute 
    // and set its value to blue.
    if (get_TagKey().Equals(HtmlTextWriterTag.Label)) {
        if (!(IsAttributeDefined(HtmlTextWriterAttribute.Style)))
 {
            AddAttribute("style", EncodeAttributeValue("color:blue"
,
                true));
            Write(get_NewLine());
            set_Indent(3);
            OutputTabs();
        }
    }

    // If an Anchor element is being 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 (get_TagKey().Equals(HtmlTextWriterTag.A)) {
        if (!(IsAttributeDefined(HtmlTextWriterAttribute.Href)))
 {
            AddAttribute("href", EncodeUrl("http://www.cohowinery.com"));
        }
    }

    // Call the FilterAttributes method of the base class.
    super.FilterAttributes();
} //FilterAttributes
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
HtmlTextWriter クラス
HtmlTextWriter メンバ
System.Web.UI 名前空間
WriteLine
TextWriter
NewLine


このページでは「.NET Framework クラス ライブラリ リファレンス」からHtmlTextWriter.NewLine プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からHtmlTextWriter.NewLine プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からHtmlTextWriter.NewLine プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

HtmlTextWriter.NewLine プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



HtmlTextWriter.NewLine プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS