• 按钮类型控件 选择类型控件


    <body>
        <form id="form1" runat="server">
        <div class="style1">
        
            <br />
            <br />
            <asp:ListBox ID="lblist" runat="server" Height="115px" Width="104px" 
                SelectionMode="Multiple">
            </asp:ListBox>
            <asp:Button ID="btnAdd" runat="server" onclick="btnAdd_Click" Text="添加" />
            <asp:Button ID="btnDel" runat="server" Text="移除" />
            <asp:ListBox ID="lbStat" runat="server" Height="116px" style="margin-top: 0px" 
                Width="100px"></asp:ListBox>
                </div>
        </form>
    </body><body>
        <form id="form1" runat="server">
        <div class="style1">
        
            <br />
            <br />
            <asp:ListBox ID="lblist" runat="server" Height="115px" Width="104px" 
                SelectionMode="Multiple">
            </asp:ListBox>
            <asp:Button ID="btnAdd" runat="server" onclick="btnAdd_Click" Text="添加" />
            <asp:Button ID="btnDel" runat="server" Text="移除" />
            <asp:ListBox ID="lbStat" runat="server" Height="116px" style="margin-top: 0px" 
                Width="100px"></asp:ListBox>
               
        </div>
        </form>
    </body><body>
        <form id="form1" runat="server">
        <div class="style1">
        
            <asp:ListBox ID="lblist" runat="server" Height="115px" Width="104px" 
                SelectionMode="Multiple">
            </asp:ListBox>
            <asp:Button ID="btnAdd" runat="server" onclick="btnAdd_Click" Text="添加" />
            <asp:Button ID="btnDel" runat="server" Text="移除" />
            <asp:ListBox ID="lbStat" runat="server" Height="116px" style="margin-top: 0px" 
                Width="100px"></asp:ListBox>
               
        </div>
        </form>
    </body><body>
        <form id="form1" runat="server">
        <div class="style1">
        
           
            <asp:ListBox ID="lblist" runat="server" Height="115px" Width="104px" 
                SelectionMode="Multiple">
            </asp:ListBox>
            <asp:Button ID="btnAdd" runat="server" onclick="btnAdd_Click" Text="添加" />
            <asp:Button ID="btnDel" runat="server" Text="移除" />
            <asp:ListBox ID="lbStat" runat="server" Height="116px" style="margin-top: 0px" 
                Width="100px"></asp:ListBox>
                  </div>
        </form>
    </body><body>
        <form id="form1" runat="server">
        <div class="style1">
        
            <asp:ListBox ID="lblist" runat="server" Height="115px" Width="104px" 
                SelectionMode="Multiple">
            </asp:ListBox>
            <asp:Button ID="btnAdd" runat="server" onclick="btnAdd_Click" Text="添加" />
            <asp:Button ID="btnDel" runat="server" Text="移除" />
            <asp:ListBox ID="lbStat" runat="server" Height="116px" style="margin-top: 0px" 
                Width="100px"></asp:ListBox>
          
        </div>
        </form>
    </body>


    后台:

    protected void Page_Load(object sender, EventArgs e)
        {
            AddUser();
    
        }
        private void AddUser()
        {
            lblist.Items.Add("11");
            lblist.Items.Add("22");
            lblist.Items.Add("33");
            lblist.Items.Add("44");
            lblist.Items.Add("55");
            lblist.Items.Add("66");
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            for (int i = 0; i <lblist.Items.Count; i++)
            {
                if (lblist.Items[i].Selected)
                {
                    ListItem li = lbStat.Items.FindByValue(lblist.Items[i].Text);
                    if (li == null)
                    {
                        lbStat.Items.Add(lblist.Items[i].Text);
                    }
                }
            }
            lblist.ClearSelection();//清除项目中的选中状态
        }
     protected void btnDel_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < lbStat.Items.Count; i++)
            {
                if (lbStat.Items[i].Selected)
                {
                    lbStat.Items.RemoveAt(i);
                }
                lblist.ClearSelection();
            }
        }
  • 相关阅读:
    IP地址结构分类(包括主机号和网络好计算)
    抓包工具fiddler的Https证书设置
    获取目录结构,并写到txt文档里
    十五、React:简单点餐实例:知识点,html解析写法
    git commit -m 和 git commit -am 区别
    用Git管理项目进行版本控制
    pycharm 设置项目的编译器
    十四、 React路由(react-router4.x): 动态路由、get传值、React中使用url模块
    十三、react-router 4.x的基本配置
    进程间的通讯
  • 原文地址:https://www.cnblogs.com/qiushuixizhao/p/3310083.html
Copyright © 2020-2023  润新知