<div>
<asp:Button ID=”Button1″ runat=”server” CommandArgument=”fbi” CommandName=”sort”
OnCommand=”Button1_Command” Text=”我是FBI” />
<asp:Button ID=”Button2″ runat=”server” CommandArgument=”fu” CommandName=”sort” OnCommand=”Button1_Command”
Text=”我是福尔摩斯” />
<asp:Button ID=”Button3″ runat=”server” CommandArgument=”cia” CommandName=”ccia”
OnCommand=”Button1_Command” Text=”我是CIA” />
<asp:Button ID=”Button4″ runat=”server” CommandArgument=”cia” CommandName=”bande”
OnCommand=”Button1_Command” Text=”我是邦德” /><br />
<asp:Label ID=”Label1″ runat=”server” Text=”Label”></asp:Label><br />
<br />
<asp:Label ID=”Label2″ runat=”server” Text=”Label”></asp:Label><br />
<br />
<asp:Label ID=”Label3″ runat=”server” Text=”Label”></asp:Label><br />
<br />
<br />
<asp:Label ID=”Label4″ runat=”server” Text=”Label”></asp:Label><br />
<br />
代码如下:要注意看,关键在这里啊!
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Command(object sender, CommandEventArgs e)
{
switch (e.CommandName)
{
case “sort”:
Sort_Listt((String)e.CommandArgument);
break;
case “ccia”:
Label3.Text = “我是一个CIA,帅吧!”;
break;
case “bande”:
Label4.Text = “我是邦德啊!假的!!”;
break;
}
}
void Sort_Listt(string commandArgument)
{
switch (commandArgument)
{
case “fbi”:
Label1.Text = “真的!我是一个FBI”;
break;
case “fu”:
Label2.Text = “假的!我不是福尔摩斯,它已经老死了!!”;
break;
}
}
转载于:https://www.cnblogs.com/footleg/archive/2008/03/05/1092648.html
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/35476.html