UrlPropertyAttribute 생성자

정의

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

오버로드

UrlPropertyAttribute()

UrlPropertyAttribute 클래스의 새로운 기본 인스턴스를 초기화합니다.

UrlPropertyAttribute(String)

UrlPropertyAttribute 속성을 지정된 문자열로 설정하여 Filter 클래스의 새 인스턴스를 초기화합니다.

UrlPropertyAttribute()

UrlPropertyAttribute 클래스의 새로운 기본 인스턴스를 초기화합니다.

public:
 UrlPropertyAttribute();
public UrlPropertyAttribute ();
Public Sub New ()

예제

다음 코드 예제에서는 URL 관련 속성을 구현 하는 클래스를 보여 줍니다. 이 코드 예제에서는 기본값 UrlPropertyAttribute 특성이 적용 되는 TargetUrl 의 속성을 CustomHyperLinkControl 클래스입니다. 특성은 모든 URL 형식에 기본 파일 필터 집합을 지정에 대 한 지원을 나타냅니다 "*. *".

public class CustomHyperLinkControl : WebControl
{
    public CustomHyperLinkControl() { }

    // The TargetUrl property represents the URL that 
    // the custom hyperlink control navigates to.
    [UrlProperty()]
    public string TargetUrl
    {
        get
        {
            string s = (string)ViewState["TargetUrl"];
            return ((s == null) ? String.Empty : s);
        }
        set
        {
            ViewState["TargetUrl"] = value;
        }
    }

    // The Text property represents the visible text that 
    // the custom hyperlink control is displayed with.        
    public virtual string Text
    {
        get
        {
            string s = (string)ViewState["Text"];
            return ((s == null) ? String.Empty : s);
        }
        set
        {
            ViewState["Text"] = value;
        }
    }

    // Implement this method to render the control.
}
Public Class CustomHyperLinkControl
    Inherits WebControl

    Public Sub New()
    End Sub

    ' The TargetUrl property represents the URL that 
    ' the custom hyperlink control navigates to.        
    <UrlProperty()> _
    Public Property TargetUrl() As String
        Get
            Dim s As String = CStr(ViewState("TargetUrl"))
            If (s Is Nothing) Then
                Return String.Empty
            Else
                Return s
            End If
        End Get
        Set(ByVal value As String)
            ViewState("TargetUrl") = value
        End Set
    End Property

    ' The Text property represents the visible text that 
    ' the custom hyperlink control is displayed with.        

    Public Overridable Property [Text]() As String
        Get
            Dim s As String = CStr(ViewState("Text"))
            If (s Is Nothing) Then
                Return String.Empty
            Else
                Return s
            End If
        End Get
        Set(ByVal value As String)
            ViewState("Text") = value
        End Set
    End Property

    ' Implement method to render the control.

End Class

설명

기본 인스턴스는 UrlPropertyAttribute 클래스를 사용 하 여 초기화 합니다 Filter 속성 값으로 설정 "*.*"입니다.

적용 대상

UrlPropertyAttribute(String)

UrlPropertyAttribute 속성을 지정된 문자열로 설정하여 Filter 클래스의 새 인스턴스를 초기화합니다.

public:
 UrlPropertyAttribute(System::String ^ filter);
public UrlPropertyAttribute (string filter);
new System.Web.UI.UrlPropertyAttribute : string -> System.Web.UI.UrlPropertyAttribute
Public Sub New (filter As String)

매개 변수

filter
String

URL 관련 속성과 연결된 파일 필터입니다.

예제

다음 코드 예제에서는 URL 관련 속성을 구현 하는 클래스를 보여 줍니다. 이 코드 예제에서는 UrlPropertyAttribute 특성이 적용 되는 TargetUrl 의 속성을 CustomHyperLinkControl 클래스입니다. ASP.NET 파일에 대 한 특정 파일 필터를 설정 하는 특성입니다.

public class CustomHyperLinkControl : WebControl
{
    public CustomHyperLinkControl() { }

    // The TargetUrl property represents the URL that 
    // the custom hyperlink control navigates to.
    [UrlProperty("*.aspx")]
    public string TargetUrl
    {
        get
        {
            string s = (string)ViewState["TargetUrl"];
            return ((s == null) ? String.Empty : s);
        }
        set
        {
            ViewState["TargetUrl"] = value;
        }
    }

    // The Text property represents the visible text that 
    // the custom hyperlink control is displayed with.        
    public virtual string Text
    {
        get
        {
            string s = (string)ViewState["Text"];
            return ((s == null) ? String.Empty : s);
        }
        set
        {
            ViewState["Text"] = value;
        }
    }

    // Implement method to render the control.
}
Public Class CustomHyperLinkControl
    Inherits WebControl

    Public Sub New()
    End Sub

    ' The TargetUrl property represents the URL that 
    ' the custom hyperlink control navigates to.        
    <UrlProperty("*.aspx")> _
    Public Property TargetUrl() As String
        Get
            Dim s As String = CStr(ViewState("TargetUrl"))
            If (s Is Nothing) Then
                Return String.Empty
            Else
                Return s
            End If
        End Get
        Set(ByVal value As String)
            ViewState("TargetUrl") = value
        End Set
    End Property

    ' The Text property represents the visible text that 
    ' the custom hyperlink control is displayed with.                
    Public Overridable Property [Text]() As String
        Get
            Dim s As String = CStr(ViewState("Text"))
            If (s Is Nothing) Then
                Return String.Empty
            Else
                Return s
            End If
        End Get
        Set(ByVal value As String)
            ViewState("Text") = value
        End Set
    End Property

    ' Implement method to render the control.

End Class

설명

인스턴스를 UrlPropertyAttribute 사용 하 여이 생성자를 사용 하 여 생성 된 클래스는 초기화를 Filter 속성이로 설정 filter합니다.

적용 대상