AttributeCollection.Item[String] Свойство
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Возвращает или задает указанное значение атрибута для серверного элемента управления.
public:
property System::String ^ default[System::String ^] { System::String ^ get(System::String ^ key); void set(System::String ^ key, System::String ^ value); };
public string this[string key] { get; set; }
member this.Item(string) : string with get, set
Default Public Property Item(key As String) As String
Параметры
- key
- String
Расположение атрибута в коллекции.
Значение свойства
Значение атрибута.
Примеры
В следующем примере показано, как задать динамический атрибут HTML onblur для выполнения команды ECMAScript (JavaScript), когда TextBox элемент управления веб-сервера теряет фокус.
<!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 runat="server">
<title>Attributes Property of a Web Control</title>
<script language="c#" runat="server">
void Page_Load(Object sender, EventArgs e) {
TextBox1.Attributes["onblur"]="javascript:alert('Hello! Focus lost from text box!!');";
}
</script>
</head>
<body>
<h3>Attributes Property of a Web Control</h3>
<form id="form1" runat="server">
<asp:TextBox id="TextBox1" columns="54"
Text="Click here and then tab out of this text box"
runat="server"/>
</form>
</body>
</html>
<!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 runat="server">
<title>Attributes Property of a Web Control</title>
<script language="vb" runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
TextBox1.Attributes("onblur")="javascript:alert('Hello! Focus lost from text box!!');"
End Sub
</script>
</head>
<body>
<h3>Attributes Property of a Web Control</h3>
<form id="form1" runat="server">
<asp:TextBox id="TextBox1" columns="54"
Text="Click here and then tab out of this text box"
runat="server"/>
</form>
</body>
</html>
Комментарии
Вы можете добавить атрибут или получить его из элемента управления сервера ASP.NET, использующего это свойство.