UrlPropertyAttribute コンストラクタ ()
アセンブリ: System.Web (system.web.dll 内)



URL 固有のプロパティを実装するクラスのコード例を次に示します。このコード例では、既定の UrlPropertyAttribute 属性を CustomHyperLinkControl クラスの TargetUrl プロパティに適用します。この属性は、すべての URL をサポートしていることを示し、"*.*" に設定された既定のファイル フィルタを指定しています。
Public Class CustomHyperLinkControl Inherits WebControl Public Sub New() End Sub 'New ' 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 'CustomHyperLinkControl
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. }

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


UrlPropertyAttribute コンストラクタ (String)
アセンブリ: System.Web (system.web.dll 内)



URL 固有のプロパティを実装するクラスのコード例を次に示します。このコード例では、UrlPropertyAttribute 属性を CustomHyperLinkControl クラスの TargetUrl プロパティに適用します。この属性は、ASP.NET ファイルに固有のファイル フィルタを設定します。
Public Class CustomHyperLinkControl Inherits WebControl Public Sub New() End Sub 'New ' 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 'CustomHyperLinkControl
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. }

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


UrlPropertyAttribute コンストラクタ
- UrlPropertyAttribute コンストラクタ ()のページへのリンク