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 созданного с помощью этого конструктора, инициализируется свойством, равным Filterfilter.