XhtmlTextWriter.IsValidFormAttribute メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > XhtmlTextWriter.IsValidFormAttribute メソッドの意味・解説 

XhtmlTextWriter.IsValidFormAttribute メソッド

メモ : このメソッドは、.NET Framework version 2.0 で新しく追加されたものです。

XHTML 属性をチェックして、form 要素の開始タグにその XHTML 属性をレンダリングできるかどうかを確認します。要求元デバイスの XHTML ドキュメント タイプがサポートしているかどうかによって条件付きで属性をレンダリングする場合、IsValidFormAttribute メソッドを呼び出します。

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

Public Overrides Function
 IsValidFormAttribute ( _
    attributeName As String _
) As Boolean
Dim instance As XhtmlTextWriter
Dim attributeName As String
Dim returnValue As Boolean

returnValue = instance.IsValidFormAttribute(attributeName)
public override bool IsValidFormAttribute (
    string attributeName
)
public:
virtual bool IsValidFormAttribute (
    String^ attributeName
) override
public boolean IsValidFormAttribute (
    String attributeName
)
public override function IsValidFormAttribute
 (
    attributeName : String
) : boolean

パラメータ

attributeName

確認対象の属性名。

戻り値
属性を form に適用できる場合は true。それ以外の場合は false。

使用例使用例

次のコード例は、カスタム Label コントロールと、このコントロールの内容を XHTML にレンダリングするアダプタを作成する大きなコード例の一部です。

このコード例では、attTest という名前の Boolean 変数を作成し、この変数を、IsValidFormAttribute メソッド呼び出しからの戻り値に設定する方法を示します。このメソッドは文字列 "style" をパラメータの引数として渡します。IsValidFormAttribute メソッドが true を返す場合、コントロールと関連付けられるスタイルが HtmlTextWriter.EnterStyle メソッドと HtmlTextWriter.ExitStyle メソッドを使用してレンダリングされます。attTest 値が false の場合、スタイルはレンダリングされません。代わりに、ページは、コントロール用のテキスト、WriteBreak メソッドでレンダリングされる br/ 要素、およびコントロールの XHTML コンテンツが条件付きでレンダリングされていることをユーザーに通知するテキスト文字列を表示します。

このコード例は、XhtmlTextWriter クラスのトピックで取り上げているコード例の一部分です。

' Override the Render method.
Protected Overrides Sub
 Render(ByVal writer As HtmlTextWriter)

    ' Create an instance of the XhtmlTextWriter class, 
    ' named w, and cast the HtmlTextWriter passed 
    ' in the writer parameter to w.
    Dim w As XhtmlTextWriter = New
 XhtmlTextWriter(writer)

    ' Create a string variable, named value, to hold
    ' the control's Text property value.
    Dim value As String
 = Control.Text

    ' Create a Boolean variable, named attTest,
    ' to test whether the Style attribute is 
    ' valid in the page that the control is
    ' rendered to.
    Dim attTest As Boolean
 = w.IsValidFormAttribute("style")

    ' Check whether attTest is true or false.
    ' If true, a style is applied to the XHTML
    ' content. If false, no style is applied.
    If (attTest = True) Then
        w.EnterStyle(Control.ControlStyle)
    End If

    ' Write the Text property value of the control,
    ' a <br> element, and a string.
    w.Write(value)
    w.WriteBreak()
    w.Write("This control conditionally rendered its styles for
 XHTML.")

    ' Check whether attTest is true or false.
    ' If true, the XHTML style is closed.
    ' If false, nothing is rendered.
    If (attTest = True) Then
        w.ExitStyle(Control.ControlStyle)
    End If

End Sub 'Render
protected override void Render(HtmlTextWriter
 writer)
{
    // Create an instance of the XhtmlTextWriter class,
    // named w, and cast the HtmlTextWriter passed 
    // in the writer parameter to w.
    XhtmlTextWriter w = new XhtmlTextWriter(writer);

    // Create a string variable, named value, to hold
    // the control's Text property value.
    String value = Control.Text;

    
    // Create a Boolean variable, named attTest,
    // to test whether the Style attribute is 
    // valid in the page that the control is
    // rendered to.
    Boolean attTest = w.IsValidFormAttribute("style");

    // Check whether attTest is true or false.
    // If true, a style is applied to the XHTML
    // content. If false, no style is applied.
    if (attTest)
        w.EnterStyle(Control.ControlStyle);

    // Write the Text property value of the control,
    // a <br> element, and a string.
    w.Write(value);
    w.WriteBreak();
    w.Write("This control conditionally rendered its styles for
 XHTML.");

    // Check whether attTest is true or false.
    // If true, the XHTML style is closed.
    // If false, nothing is rendered.
    if (attTest)
        w.ExitStyle(Control.ControlStyle);
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
XhtmlTextWriter クラス
XhtmlTextWriter メンバ
System.Web.UI 名前空間



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

XhtmlTextWriter.IsValidFormAttribute メソッドのお隣キーワード
検索ランキング

   

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



XhtmlTextWriter.IsValidFormAttribute メソッドのページの著作権

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

©2026 GRAS Group, Inc.RSS