AttributeCollection.Item[String] Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets a specified attribute value for a server control.
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
Parameters
- key
- String
The location of the attribute in the collection.
Property Value
The attribute value.
Examples
The following example shows how to set a dynamic HTML onblur
attribute to run an ECMAScript (JavaScript) command when a TextBox Web server control loses focus.
<!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>
Remarks
You can add an attribute to or retrieve one from an ASP.NET server control that uses this property.
Applies to
See also
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기