zoukankan      html  css  js  c++  java
  • ASP.NET 2.0中隐藏listbox的某一项

    在asp.net 2.0中,可以隐藏listbox中的某一项,比如
    ListItem item = new ListItem(text, value, enabled);
    当然,也可以用

    item.Enabled = false;

    虽然在页面中隐藏了,但依然可以用代码来访问隐藏的选项的,下面是一个例子
    <%@ Page Language="C#" %>
     
    <script runat="server">
       protected 
    void Page_Load(object sender, EventArgs e)
        
    {
            
    if (!Page.IsPostBack)
           
    {           
                              ListItem[] items 
    = new ListItem[]
                                    

                                       
    new ListItem("Item 1""Value 1"),

                                        
    new ListItem("Item 2""Value 2"false),

                                        
    new ListItem("Item 3""Value 3"),

                                        
    new ListItem("Item 4""Value 4")
                                    }
    ;
                ListBox1.Items.AddRange(items);
            }

        }

        protected 
    void Button1_Click(object sender, EventArgs e)
        
    {
            foreach (ListItem item 
    in ListBox1.Items)
            
    {
               Response.Write(item.Text 
    + " enabled=" + item.Enabled + "<br>");
            }

        }
        
    </script>

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        
    <title>Untitled Page</title>
    </head>
    <body>
        
    <form id="form1" runat="server">
        
    <div>
            
    <asp:ListBox ID="ListBox1" runat="server" />
      
    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /></div>
        
    </form>
    </body>
    </html>
  • 相关阅读:
    简单搭建ELK日志分析平台及常见问题汇总
    【Java】开发23中设计模式详解(转载)
    【微服务】dubbo微服务的总结及结合Spring的实例
    【服务端】知识架构规划
    【java】数据缓存之 EhCache缓存
    【java】数据缓存之 Redis
    【java】多线程编程(不断扩充,但不拆分)
    【MySQL】mysql 存储过程应用
    【MySQL】基础知识-case when函数
    【MySQL】 join连接使用基本知识
  • 原文地址:https://www.cnblogs.com/ghd258/p/262995.html
Copyright © 2011-2022 走看看