PageAdapter.RenderBeginHyperlink 메서드

정의

여는 하이퍼링크 태그를 응답 스트림에 렌더링합니다.

오버로드

Name Description
RenderBeginHyperlink(HtmlTextWriter, String, Boolean, String)

대상 URL을 포함하는 여는 하이퍼링크 태그를 응답 스트림에 렌더링합니다.

RenderBeginHyperlink(HtmlTextWriter, String, Boolean, String, String)

대상 URL과 응답 스트림에 대한 액세스 키를 포함하는 여는 하이퍼링크 태그를 렌더링합니다.

RenderBeginHyperlink(HtmlTextWriter, String, Boolean, String)

대상 URL을 포함하는 여는 하이퍼링크 태그를 응답 스트림에 렌더링합니다.

public:
 virtual void RenderBeginHyperlink(System::Web::UI::HtmlTextWriter ^ writer, System::String ^ targetUrl, bool encodeUrl, System::String ^ softkeyLabel);
public virtual void RenderBeginHyperlink(System.Web.UI.HtmlTextWriter writer, string targetUrl, bool encodeUrl, string softkeyLabel);
abstract member RenderBeginHyperlink : System.Web.UI.HtmlTextWriter * string * bool * string -> unit
override this.RenderBeginHyperlink : System.Web.UI.HtmlTextWriter * string * bool * string -> unit
Public Overridable Sub RenderBeginHyperlink (writer As HtmlTextWriter, targetUrl As String, encodeUrl As Boolean, softkeyLabel As String)

매개 변수

writer
HtmlTextWriter

HtmlTextWriter 대상별 출력을 렌더링하는 포함하는 메서드입니다.

targetUrl
String

String 링크의 대상 URL을 보유하는 값입니다.

encodeUrl
Boolean

true 스트림 출력을 인코딩하는 데 사용 HtmlAttributeEncode(String) 하려면 .이고, false그렇지 않으면 .입니다.

softkeyLabel
String

String 소프트 키 레이블로 사용할 값입니다.

예제

다음 코드 예제에서는 클래스에서 명명 된 CustomPageAdapter 클래스를 파생 하 고 메서드를 재정의 PageAdapter 하는 RenderBeginHyperlink 방법을 보여 줍니다. 이 메서드는 RenderBeginHyperlink 현재 페이지에 대한 참조를 포함하는 하이퍼링크에 명명 src 된 특성을 추가합니다. 연결된 페이지에서 CustomPageAdapter 렌더링된 모든 하이퍼링크에는 특성이 src 포함됩니다.

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" );
    }
}
Imports System.IO
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.Adapters

' 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
End Class

설명

이 메서드는 RenderBeginHyperlink 여는 하이퍼링크 태그를 씁니다. 이 writer 태그의 HtmlTextWriter형식은 다음과 같습니다.

<a href=" targetUrl ">

상속자 참고

클래스에서 PageAdapter 상속하는 경우 여는 하이퍼링크 태그에 대해 다른 형식을 작성하거나 추가 태그 특성을 작성하도록 메서드를 재정 RenderBeginHyperlink(HtmlTextWriter, String, Boolean, String) 의할 수 있습니다. 예를 들어 기본 메서드는 RenderBeginHyperlink(HtmlTextWriter, String, Boolean, String) 에 대한 softkeyLabel특성을 작성하지 않습니다.

추가 정보

적용 대상

RenderBeginHyperlink(HtmlTextWriter, String, Boolean, String, String)

대상 URL과 응답 스트림에 대한 액세스 키를 포함하는 여는 하이퍼링크 태그를 렌더링합니다.

public:
 virtual void RenderBeginHyperlink(System::Web::UI::HtmlTextWriter ^ writer, System::String ^ targetUrl, bool encodeUrl, System::String ^ softkeyLabel, System::String ^ accessKey);
public virtual void RenderBeginHyperlink(System.Web.UI.HtmlTextWriter writer, string targetUrl, bool encodeUrl, string softkeyLabel, string accessKey);
abstract member RenderBeginHyperlink : System.Web.UI.HtmlTextWriter * string * bool * string * string -> unit
override this.RenderBeginHyperlink : System.Web.UI.HtmlTextWriter * string * bool * string * string -> unit
Public Overridable Sub RenderBeginHyperlink (writer As HtmlTextWriter, targetUrl As String, encodeUrl As Boolean, softkeyLabel As String, accessKey As String)

매개 변수

writer
HtmlTextWriter

HtmlTextWriter 대상별 출력을 렌더링하는 포함하는 메서드입니다.

targetUrl
String

String 링크의 대상 URL을 보유하는 값입니다.

encodeUrl
Boolean

true 스트림 출력을 인코딩하는 데 사용 HtmlAttributeEncode(String) 하려면 .이고, false그렇지 않으면 .입니다.

softkeyLabel
String

String 소프트 키 레이블로 사용할 값입니다.

accessKey
String

String 만들 링크의 특성에 accessKey 할당할 값입니다.

예외

accessKey 가 한 문자보다 깁니다.

예제

다음 코드 예제에서는 클래스에서 명명 된 CustomPageAdapter 클래스를 파생 하 고 메서드를 재정의 PageAdapter 하는 RenderBeginHyperlink 방법을 보여 줍니다. RenderBeginHyperlink 는 현재 페이지에 대한 참조를 포함하는 하이퍼링크에 명명 src 된 특성을 추가합니다. 연결된 페이지에서 CustomPageAdapter 렌더링된 모든 하이퍼링크에는 특성이 src 포함됩니다.

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" );
    }
}
Imports System.IO
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.Adapters

' 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
End Class

설명

이 메서드는 RenderBeginHyperlink 여는 하이퍼링크 태그를 씁니다. 개체인 writer 경우 HtmlTextWriter 이 태그의 형식은 다음과 같습니다.

<a href=" targetUrl " accessKey=" accessKey ">

상속자 참고

클래스에서 PageAdapter 상속하는 경우 여는 하이퍼링크 태그에 대해 다른 형식을 작성하거나 추가 태그 특성을 작성하도록 메서드를 재정 RenderBeginHyperlink(HtmlTextWriter, String, Boolean, String, String) 의할 수 있습니다. 예를 들어 기본 메서드는 RenderBeginHyperlink(HtmlTextWriter, String, Boolean, String, String) 에 대한 softkeyLabel특성을 작성하지 않습니다.

추가 정보

적용 대상