文章出處:http://www.aspCool.com 轉載請注明,謝謝!
*/
操作服務器控件的事件
每一個asp+的服務器控件都有自己的屬性,方法和事件。asp+的開發者現在可以清楚的修改和交互自己的頁面
下面的這個例子,我們用到了兩個服務器控件<asp:button runat=server> ,<asp:label runat=server>
和button 的 click 事件
<html>
<head>
<link rel="stylesheet"href="intro.css">
</head>
<script language="VB" runat=server>
Sub SubmitBtn_Click(Sender As Object, E As EventArgs)
Message.Text = "Hi " & Name.Text & ", you selected: " & Category.SelectedItem.Text
End Sub
</script>
<body>
<center>
<form action="intro6.aspx" method="post" runat="server">
<asp:adrotator AdvertisementFile="ads.xml" BorderColor="black" BorderWidth=1 runat="server"/>
<h3> Name: <asp:textbox id="Name" runat="server"/>
Category: <asp:dropdownlist id="Category" runat=server>
<asp:listitem>psychology</asp:listitem>
<asp:listitem>business</asp:listitem>
<asp:listitem>popular_comp</asp:listitem>
</asp:dropdownlist>
<asp:button type=submit text="Lookup" OnClick="SubmitBtn_Click" runat="server"/>
<p>
<asp:label id="Message" runat="server"/>
</form>
</center>
</body>
</html>
這個程序的演示地址是
http://tutorial.superexpert.com/quickstart/aspplus/samples/webforms/intro/intro6.aspx
這個簡單的例子,我們以前在例子3中也已經簡單的演示過,但是我們現在用了一種簡單和給為清晰的方法來演示新版本的服務器控件的功能