다음을 통해 공유


HideDisabledControlAdapter 클래스

정의

특정 브라우저의 기본 태그나 동작을 수정할 수 있도록 연결된 웹 컨트롤의 렌더링 기능을 제공합니다.

public ref class HideDisabledControlAdapter : System::Web::UI::WebControls::Adapters::WebControlAdapter
public class HideDisabledControlAdapter : System.Web.UI.WebControls.Adapters.WebControlAdapter
type HideDisabledControlAdapter = class
    inherit WebControlAdapter
Public Class HideDisabledControlAdapter
Inherits WebControlAdapter
상속
HideDisabledControlAdapter

예제

다음 코드 예제에서는 사용 및 사용 안 함 HideDisabledControlAdapter 상태에서 컨트롤을 Label 표시 하도록 클래스를 확장 하는 방법을 보여 줍니다. 이 예제에는 다음 세 부분이 포함됩니다.

  • 클래스에서 파생된 어댑터입니다 HideDisabledControlAdapter .

  • 통합 하는.aspx 파일의 Label 컨트롤 뷰 및 디바이스별 콘텐츠입니다.

  • 디바이스 유형 어댑터를 연결할 브라우저 파일입니다.

다음 코드 예제를 확장 하는 방법에 설명 합니다 HideDisabledControlAdapter 클래스입니다.

using System;
using System.Web;
using System.Web.UI;
using System.Security.Permissions;

namespace Contoso
{
    [AspNetHostingPermission(
        SecurityAction.Demand, 
        Level = AspNetHostingPermissionLevel.Minimal)]
    [AspNetHostingPermission(
        SecurityAction.InheritanceDemand, 
        Level = AspNetHostingPermissionLevel.Minimal)]
    public class HideDisabledControlContosoAdapter:
        System.Web.UI.WebControls.Adapters.HideDisabledControlAdapter
    {
        // Link the Label control to the adapter.
        protected new System.Web.UI.WebControls.Label Control
        {
            get
            {
                return (System.Web.UI.WebControls.Label)base.Control;
            }
        }

        // Do not render the Contoso controls if Enabled is false.
        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            if (Control.ID.StartsWith("Contoso"))
            {
                if (!Control.Enabled)
                {
                    return;
                }
            }

            base.Render(writer);
        }
    }
}
Imports System.Web
Imports System.Web.UI
Imports System.Security.Permissions

Namespace Contoso
    <AspNetHostingPermission( _
        SecurityAction.Demand, _
        Level:=AspNetHostingPermissionLevel.Minimal)> _
    <AspNetHostingPermission( _
        SecurityAction.InheritanceDemand, _
        Level:=AspNetHostingPermissionLevel.Minimal)> _
    Public Class HideDisabledControlContosoAdapter
        Inherits System.Web.UI.WebControls.Adapters.HideDisabledControlAdapter
    
        Protected Overloads ReadOnly Property Control() As _
            System.Web.UI.WebControls.Label
            Get
                Return CType( _
                    MyBase.Control, _
                    System.Web.UI.WebControls.Label)
            End Get
        End Property

        ' Do not render the control if Enabled is false.
        Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
            If (Control.ID.StartsWith("Contoso")) Then
                If (Not Control.Enabled) Then
                    Return
                End If
            End If

            MyBase.Render(writer)
        End Sub
    End Class
End Namespace

다음 코드 예제에는 선언 하는 방법을 보여 줍니다.는 Label 디바이스별 콘텐츠를 사용 하 여 제어 합니다.

<%@ page language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>HideDisabledControl Adapter</title>
    <script runat="server">
        void ServerButtonClick(Object source, EventArgs args)
        {
            if (Button1.Text == "Enable Label")
            {
                ContosoLabel1.Enabled = true;
                Button1.Text = "Disable Label";
                messageLabel.Text = "The label is <b>En</b>abled";
            }
            else
            {
                ContosoLabel1.Enabled = false;
                Button1.Text = "Enable Label";
                messageLabel.Text = "The label is <b>dis</b>abled";
            }
        }
    </script>
</head>
<body style="background-color:silver">
    <form id="Form1" runat="server">
        <asp:Label id="ContosoLabel1"             
            text="Contoso Label" 
            WinCE:text="CE Label"
            BorderWidth="3" 
            BorderStyle="Inset"
            style="FONT-SIZE: xx-small"
            runat="server">
            </asp:Label>
        <br />
        <asp:Button id="Button1" 
            text="Disable Label"
            OnClick="ServerButtonClick" 
            runat="server" />
        <br />    
        <asp:Label id="messageLabel" 
            runat="server" 
            style="FONT-SIZE: xx-small"
            AssociatedControlID="Button1">
            <i>Select the button to disable the label.</i>
        </asp:Label>
    </form>
</body>
</html>
<%@ page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>HideDisabledControl Adapter</title>
    <script runat="server">
        Sub ServerButtonClick(ByVal source As Object, ByVal args As EventArgs)
            If (Button1.Text.Equals("Enable Label")) Then
                ContosoLabel1.Enabled = True
                Button1.Text = "Disable Label"
                messageLabel.Text = "The label is <b>En</b>abled"
            Else
                ContosoLabel1.Enabled = False
                Button1.Text = "Enable Label"
                messageLabel.Text = "The label is <b>dis</b>abled"
            End If
        End Sub
    </script>
</head>
<body style="background-color:silver">
    <form id="Form1" runat="server">
        <asp:Label id="ContosoLabel1"             
            text="Contoso Label" 
            WinCE:text="CE Label"
            BorderWidth="3" 
            BorderStyle="Inset"
            style="FONT-SIZE: xx-small"
            runat="server">
            </asp:Label>
        <br />
        <asp:Button id="Button1" 
            text="Disable Label"
            OnClick="ServerButtonClick" 
            runat="server" />
        <br />    
        <asp:Label id="messageLabel" 
            runat="server" 
            style="FONT-SIZE: xx-small"
            AssociatedControlID="Button1">
            <i>Select the button to disable the label.</i>
        </asp:Label>
    </form>
</body>
</html>

다음 코드 예제에서는 Windows CE .NET에서 실행 중인 브라우저에 대 한 사용자 지정 어댑터에 컨트롤을 연결 Label 하는 방법을 보여 줍니다.

설명

클래스는 HideDisabledControlAdapter 특정 브라우저에 대한 기본 태그 또는 동작을 수정하도록 연결된 WebControl 컨트롤을 조정합니다. 클래스를 HideDisabledControlAdapter 확장하여 컨트롤의 WebControl 렌더링을 추가로 사용자 지정할 수 있습니다.

어댑터는 페이지 또는 컨트롤의 수명 주기에서 하나 이상의 단계를 인수하는 구성 요소에 .NET Framework 컴파일됩니다. 클래스를 HideDisabledControlAdapter 확장하면 컨트롤의 WebControl 수명 주기 단계에 액세스할 수 있습니다. 자세한 내용은 적응형 컨트롤 동작의 아키텍처 개요를 참조하세요.

어댑터에 대한 초기 요청으로 인해 .NET Framework 요청 브라우저의 특성을 고려하여 컨트롤에 대한 매핑된 어댑터를 검색합니다. 브라우저 정의 파일은 클래스에서 HttpBrowserCapabilities 클라이언트 브라우저의 특성을 식별하고 어댑터를 브라우저 유형에 매핑하는 데 사용됩니다. 자세한 내용은 적응형 컨트롤 동작의 아키텍처 개요를 참조하세요.

생성자

HideDisabledControlAdapter()

HideDisabledControlAdapter 클래스의 새 인스턴스를 초기화합니다.

속성

Browser

현재 HTTP 요청을 하는 클라이언트의 브라우저 기능에 대한 참조를 가져옵니다.

(다음에서 상속됨 ControlAdapter)
Control

이 컨트롤 어댑터가 연결된 웹 컨트롤에 대한 참조를 가져옵니다.

(다음에서 상속됨 WebControlAdapter)
IsEnabled

웹 컨트롤 및 모든 부모 컨트롤을 사용할 수 있는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 WebControlAdapter)
Page

이 어댑터와 연결된 컨트롤이 있는 페이지에 대한 참조를 가져옵니다.

(다음에서 상속됨 ControlAdapter)
PageAdapter

연결된 컨트롤이 있는 페이지의 페이지 어댑터에 대한 참조를 가져옵니다.

(다음에서 상속됨 ControlAdapter)

메서드

BeginRender(HtmlTextWriter)

컨트롤의 렌더링 전에 호출됩니다. 파생 어댑터 클래스에서 특정 대상에는 필요하지만 HTML 브라우저에는 필요하지 않은 여는 태그를 생성합니다.

(다음에서 상속됨 ControlAdapter)
CreateChildControls()

합성 컨트롤의 대상별 자식 컨트롤을 만듭니다.

(다음에서 상속됨 ControlAdapter)
EndRender(HtmlTextWriter)

컨트롤의 렌더링 후에 호출됩니다. 파생 어댑터 클래스에서 특정 대상에는 필요하지만 HTML 브라우저에는 필요하지 않은 닫는 태그를 생성합니다.

(다음에서 상속됨 ControlAdapter)
Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
LoadAdapterControlState(Object)

이 컨트롤 어댑터와 연결된 컨트롤이 있는 페이지에 대한 이전의 요청 중 SaveAdapterControlState()에서 저장한 어댑터 컨트롤 상태 정보를 로드합니다.

(다음에서 상속됨 ControlAdapter)
LoadAdapterViewState(Object)

이 컨트롤 어댑터와 연결된 컨트롤이 있는 페이지에 대한 이전 요청 중 SaveAdapterViewState()에서 저장한 어댑터 뷰 상태 정보를 로드합니다.

(다음에서 상속됨 ControlAdapter)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
OnInit(EventArgs)

연결된 컨트롤의 OnInit(EventArgs) 메서드를 재정의합니다.

(다음에서 상속됨 ControlAdapter)
OnLoad(EventArgs)

연결된 컨트롤의 OnLoad(EventArgs) 메서드를 재정의합니다.

(다음에서 상속됨 ControlAdapter)
OnPreRender(EventArgs)

연결된 컨트롤의 OnPreRender(EventArgs) 메서드를 재정의합니다.

(다음에서 상속됨 ControlAdapter)
OnUnload(EventArgs)

연결된 컨트롤의 OnUnload(EventArgs) 메서드를 재정의합니다.

(다음에서 상속됨 ControlAdapter)
Render(HtmlTextWriter)

연결된 웹 컨트롤을 HTML로 출력 스트림에 씁니다.

RenderBeginTag(HtmlTextWriter)

대상 브라우저로 전송되는 태그 안에 웹 컨트롤의 시작 태그를 만듭니다.

(다음에서 상속됨 WebControlAdapter)
RenderChildren(HtmlTextWriter)

컨트롤 어댑터가 결합되는 합성 컨트롤의 자식 컨트롤에 대한 대상별 태그를 생성합니다.

(다음에서 상속됨 ControlAdapter)
RenderContents(HtmlTextWriter)

컨트롤 어댑터가 연결된 웹 컨트롤에 대한 대상별 내부 태그를 생성합니다.

(다음에서 상속됨 WebControlAdapter)
RenderEndTag(HtmlTextWriter)

대상 브라우저로 전송되는 태그 안에 웹 컨트롤의 끝 태그를 만듭니다.

(다음에서 상속됨 WebControlAdapter)
SaveAdapterControlState()

컨트롤 어댑터의 컨트롤 상태 정보를 저장합니다.

(다음에서 상속됨 ControlAdapter)
SaveAdapterViewState()

컨트롤 어댑터의 뷰 상태 정보를 저장합니다.

(다음에서 상속됨 ControlAdapter)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보