zoukankan      html  css  js  c++  java
  • 按钮类型控件 选择类型控件

    <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();
            }
        }
  • 相关阅读:
    面向对象、构造函数的区别
    写一个function,清除字符串前后的空格。(兼容所有浏览器)
    两个DIV高度自适应方法(左右两个DIV高度一样)
    js数组去重
    input框处理删除小图标的功能
    查找显示高亮
    JSON.parse()和JSON.stringify()
    jquery封装
    怎么理解HTML语义化
    html5语义化标签
  • 原文地址:https://www.cnblogs.com/qiushuixizhao/p/3310083.html
Copyright © 2011-2022 走看看