UrlPropertyAttribute クラス
アセンブリ: System.Web (system.web.dll 内)
構文
<AttributeUsageAttribute(AttributeTargets.Property)> _ Public NotInheritable Class UrlPropertyAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Property)] public sealed class UrlPropertyAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Property)] public ref class UrlPropertyAttribute sealed : public Attribute
UrlPropertyAttribute 属性は、URL を表すコントロール プロパティに適用される属性です。UrlPropertyAttribute 属性では、文字列プロパティを URL を表すものとしてマークするのに加え、そのプロパティのフィルタ処理に使用する特定のファイルの種類を識別する Filter プロパティを定義します。
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. }
継承階層
System.Attribute
System.Web.UI.UrlPropertyAttribute
プラットフォーム
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 クラスのページへのリンク