<html>
<head>
<title>Retrieving the Attributes Collection of a Web Control</title>
<link rel="stylesheet" href="/shared/netdemos.css">
<style type="text/css">
<!--
.out {color:lime; background:navy}
.over {color:gold; background:maroon}
.click {color:navy; background:khaki}
-->
</style>
<script language="C#" runat="server">
string atts;
void showAttributes ( Object src, EventArgs e ) {
IEnumerator attribs = greeting.Attributes.Keys.GetEnumerator ( );
while ( attribs.MoveNext ( ) ) {
string key = ( string ) attribs.Current;
atts += key + " = " + greeting.Attributes [ key ] + "<br>";;
}
showme.Visible = false;
message.Text = atts;
}
</script>
</head>
<body>
<!-- #include virtual="~/shared/top.inc" -->
<div class="header"><h2>Retrieving the Attributes Collection of a Web Control</h2></div>
<hr size=1 width=92%>
<div align="center">
<form runat="server">
<p><asp:label id="greeting" runat="server"
style="font: bold 11pt; padding:10; border: 1px inset; cursor:hand"
class="out"
onMouseOver="this.className='over'"
onMouseOut="this.className='out'"
onClick="this.className='click'"
text="Greetings, earthling, welcome to ASP.NET." /></p>
<br>
<p><asp:button id="showme" onClick="showAttributes" runat="server" text="Show me" /></p>
<br>
<p><asp:label id="message" runat="server" /></p>
</form>
</div>
<hr size=1 width=92%>
<!-- #include virtual="~/shared/viewsrc.inc" -->
</body>
</html>