<html>
<head>
<title>Responding to Page and Control Events</title>
<link rel="stylesheet" href="/shared/netdemos.css">
<script language="C#" runat="server">
void Page_Load ( object src, EventArgs e ) {
// initialize button text
if ( !IsPostBack ) {
myButton.Text = thePanel.Visible ? "Hide me" : "Show me";
}
}
void ShowHide ( object src, EventArgs e ) {
thePanel.Visible = thePanel.Visible ? false : true;
myButton.Text = thePanel.Visible ? "Hide me" : "Show me";
}
void getAdProps ( object src, AdCreatedEventArgs e ) {
myLink.Text = e.AlternateText;
myLink.NavigateUrl = e.NavigateUrl;
}
</script>
</head>
<body>
<!-- #include virtual="~/shared/top.inc -->
<div class="header"><h2>Responding to <span class="hilite">Page and Control Events</span></h2></div>
<hr size=1 width=92%>
<div align="center">
<form runat="server">
<asp:button id="myButton" runat="server"
backcolor="maroon" forecolor="gold" font-bold
onClick="ShowHide" />
<asp:panel id="thePanel" runat="server" visible=false>
<p><asp:adrotator runat="server" height=140
advertisementfile="~/shared/books.xml"
bordercolor="silver" borderwidth=1
onAdCreated="getAdProps"
target="amzn" /></p>
<p><asp:hyperlink id="myLink" target="amzn" runat="server" />
</asp:panel>
</form>
</div>
<% if ( thePanel.Visible ) { %>
<hr size=1 width=92%>
<!-- #include virtual="~/shared/viewsrc.inc" -->
<% } %>
</body>
</html>