中国搜 程序源代码学习 编程源代码 直接应用在编程实践中 优秀编程书籍源码欣赏

收藏本页到>> 新浪ViVi  365Key网摘   IE收藏夹 |设为首页

 中国搜首页 >>ASP.NET相关>>事件参数Object和EventArgs的含义 C#版

<%@ Page language="C#" %>
<script runat="server">
void Button_Click( Object s, EventArgs e )
{
if (((Button) s).ID == "btnHello")
lblMessage.Text = "Hello!";
else
lblMessage.Text = "Goodbye!";
}
</script>

<html>
<head>
<title>HelloGoodbye.aspx</title>
</head>
<body>
click on the button to view the message:
<hr>
<form runat="server">
<asp:button id="btnHello" OnClick="Button_Click" Text="Say hello!" Runat="server"></asp:button>
<br>
<asp:button id="btnGoodbye" OnClick="Button_Click" Text="Say Goodbye" Runat="server"></asp:button>
<p>
</p>
<hr>
<asp:Label ID="lblMessage" Runat="server"></asp:Label>
</form>
</body>
</html>

   运行演示程序   

  ©2004   www.zhonguosou.com