zoukankan      html  css  js  c++  java
  • Button 的CommandName 用法

    <div>
            <asp:Button ID="Button1" runat="server" CommandArgument="fbi" CommandName="sort"
                OnCommand="Button1_Command" Text="我是FBI" />&nbsp; &nbsp;
            <asp:Button ID="Button2" runat="server" CommandArgument="fu" CommandName="sort" OnCommand="Button1_Command"
                Text="我是福尔摩斯" />
            &nbsp; &nbsp;<asp:Button ID="Button3" runat="server" CommandArgument="cia" CommandName="ccia"
                OnCommand="Button1_Command" Text="我是CIA" />
            &nbsp; &nbsp;<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;

            }
        }

  • 相关阅读:
    centos7以yum方式安装zabbix-agent客户端服务
    centos7搭建nexus maven私服
    pyinstaller打包python项目为windows运行exe程序
    nginx 查看安装的模块以及安装新模块
    securecrt终端显示乱码问题
    利用Anemometer做mysql慢日志的查询与可视化
    centos7安装kubernetes1.18.5
    k8s执行kubectl相关命令报错:Unable to connect to the server: x509
    postman接口测试10_导入curl请求接口
    app测试04_app性能测试之perfdog
  • 原文地址:https://www.cnblogs.com/footleg/p/1092648.html
Copyright © 2011-2022 走看看