PageAdapter クラスとは? わかりやすく解説

PageAdapter クラス

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

特定のブラウザ対応するように Web ページ調整しすべてのページ アダプタ直接または間接的な継承元となる基本クラス提供します

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

Public MustInherit Class
 PageAdapter
    Inherits ControlAdapter
public abstract class PageAdapter : ControlAdapter
public ref class PageAdapter abstract : public
 ControlAdapter
public abstract class PageAdapter extends ControlAdapter
public abstract class PageAdapter extends
 ControlAdapter
解説解説

PageAdapter クラスは、ブラウザ使用するマークアップ言語 (HTMLXHTML など) で定義された、ブラウザ特定のクラスに対して Web ページ調整する抽象クラスです。表示動作適応性多くは、HtmlTextWriter クラスから派生した専用テキスト ライタ クラスカプセル化できるので、常にページ アダプタ用意する要はありません。

派生ページ アダプタのほとんどのメンバは、Page クラスコントロール アダプタから呼び出されます。Page クラスまたはコントロール アダプタは、最初に派生ページ アダプタ存在するかどうか検出し、そのメンバ呼び出します。ページ アダプタ存在しない場合は、機能提供します

PageAdapter クラスプロパティは、次の機能提供します

使用例使用例

PageAdapter クラスから CustomPageAdapter という名前のクラス派生させ、RenderBeginHyperlink メソッドオーバーライドする方法次のコード例示しますRenderBeginHyperlink メソッドは、src という名前の属性ハイパーリンク追加します。これには、現在のページへの参照含まれます。CustomPageAdapter割り当てられページ表示されるすべてのハイパーリンクに、src 属性使用されます。

Imports System
Imports System.IO
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.Adapters
Imports Microsoft.VisualBasic

' A derived PageAdapter class.
Public Class CustomPageAdapter
    Inherits PageAdapter

    ' Override RenderBeginHyperlink to add an attribute that 
    ' references the referring page.
    Public Overrides Sub
 RenderBeginHyperlink( _
        ByVal writer As HtmlTextWriter, ByVal
 targetUrl As String, _
        ByVal encodeUrl As Boolean,
 ByVal softkeyLabel As String,
 _
        ByVal accessKey As String)

        Dim url As String

        ' Add the src attribute, if referring page URL is available.
        If Not (Page Is
 Nothing) Then
            If Not (Page.Request Is
 Nothing) Then
                If Not (Page.Request.Url Is
 Nothing) Then

                    url = Page.Request.Url.AbsoluteUri
                    If encodeUrl Then
                        url = HttpUtility.HtmlAttributeEncode(url)
                    End If
                    writer.AddAttribute("src", url)
                End If
            End If
        End If

        ' Render the accessKey attribute, if requested.
        If Not (accessKey Is
 Nothing) Then
            If accessKey.Length = 1 Then
                writer.AddAttribute("accessKey", accessKey)
            End If
        End If

        ' Add the href attribute, encode the URL if requested.
        If (encodeUrl) Then
            url = HttpUtility.HtmlAttributeEncode(targetUrl)
        Else
            url = targetUrl
        End If
        writer.AddAttribute("href", url)

        ' Render the hyperlink opening tag with the added attributes.
        writer.RenderBeginTag("a")

    End Sub ' RenderBeginHyperlink
End Class ' CustomPageAdapter
using System;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Web.UI.Adapters;

// A derived PageAdapter class.
public class CustomPageAdapter : PageAdapter
{
    // Override RenderBeginHyperlink to add an attribute that 
    // references the referring page.
    public override void RenderBeginHyperlink(
        HtmlTextWriter writer, string targetUrl,
        bool encodeUrl, string softkeyLabel,
 
        string accessKey )
    {
        string url = null;

        // Add the src attribute, if referring page URL is available.
        if( Page != null && Page.Request
 != null &&
            Page.Request.Url != null )
        {
            url = Page.Request.Url.AbsoluteUri;
            if( encodeUrl )
                url = HttpUtility.HtmlAttributeEncode( url );
            writer.AddAttribute( "src", url );
        }

        // Add the accessKey attribute, if caller requested.
        if( accessKey != null && accessKey.Length
 == 1 )
            writer.AddAttribute( "accessKey", accessKey );

        // Add the href attribute, encode the URL if requested.
        if( encodeUrl )
            url = HttpUtility.HtmlAttributeEncode( targetUrl );
        else
            url = targetUrl;
        writer.AddAttribute( "href", url );

        // Render the hyperlink opening tag with the added attributes.
        writer.RenderBeginTag( "a" );
    }
}
import System.*;
import System.IO.*;
import System.Web.*;
import System.Web.UI.*;
import System.Web.UI.Adapters.*;

// A derived PageAdapter class.
public class CustomPageAdapter extends PageAdapter
{
    // Override RenderBeginHyperlink to add an attribute that 
    // references the referring page.
    public void RenderBeginHyperlink(HtmlTextWriter
 writer, String targetUrl,
        boolean encodeUrl, String softkeyLabel, String accessKey)
    {
        String url = null;

        // Add the src attribute, if referring page URL is available.
        if (this.get_Page() != null
 && this.get_Page().get_Request() != null
 
            && this.get_Page().get_Request().get_Url()
 != null) {
            url = this.get_Page().get_Request().get_Url().get_AbsoluteUri();
            if (encodeUrl) {
                url = HttpUtility.HtmlAttributeEncode(url);
            }
            writer.AddAttribute("src", url);
        }
        // Add the accessKey attribute, if caller requested.
        if (accessKey != null && accessKey.length()
 == 1) {
            writer.AddAttribute("accessKey", accessKey);
        }
        // Add the href attribute, encode the URL if requested.
        if (encodeUrl) {
            url = HttpUtility.HtmlAttributeEncode(targetUrl);
        }
        else {
            url = targetUrl;
        }
        writer.AddAttribute("href", url);

        // Render the hyperlink opening tag with the added attributes.
        writer.RenderBeginTag("a");
    } //RenderBeginHyperlink
} //CustomPageAdapter
.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
   System.Web.UI.Adapters.ControlAdapter
    System.Web.UI.Adapters.PageAdapter
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
PageAdapter メンバ
System.Web.UI.Adapters 名前空間
ControlAdapter クラス



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

辞書ショートカット

すべての辞書の索引

「PageAdapter クラス」の関連用語

PageAdapter クラスのお隣キーワード
検索ランキング

   

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



PageAdapter クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS