zoukankan      html  css  js  c++  java
  • ASP.NET改变checkboxlist选中项字体颜色

    @ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    
    <html xmlns="http://www.w3.org/1999/xhtml" > 
    <head runat="server"> 
        <title>无标题页</title> 
    </head> 
    <body> 
        <form id="form1" runat="server"> 
        <asp:CheckBoxList ID="CheckBoxList1" runat="server" Width="728px" Height="40px" RepeatDirection="Horizontal"> 
                        <asp:ListItem Value="报纸">报纸</asp:ListItem> 
                        <asp:ListItem>杂志</asp:ListItem> 
                        <asp:ListItem>广播</asp:ListItem> 
                        <asp:ListItem>电视</asp:ListItem> 
                        <asp:ListItem>网络</asp:ListItem> 
                        <asp:ListItem>亲朋介绍</asp:ListItem> 
                        <asp:ListItem>招生简章</asp:ListItem> 
                        <asp:ListItem>招生咨询会</asp:ListItem> 
    </asp:CheckBoxList> 
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" Width="107px" /> 
        </form> 
    </body> 
    </html> 
    
    2.default.aspx.cs 
    protected void Page_Load(object sender, EventArgs e) 
        { 
        } 
        protected void Button1_Click(object sender, EventArgs e) 
        { 
            for (int i = 0; i < this.CheckBoxList1.Items.Count; i++) 
            { 
                if (this.CheckBoxList1.Items[i].Selected == true) 
                { 
                   this.CheckBoxList1.Items[i].Text = this.CheckBoxList1.Items[i].Text.IndexOf("font") == -1 ? "<font color=‘red’>" + this.CheckBoxList1.Items[i].Text + "</font>" : this.CheckBoxList1.Items[i].Text.Replace("Black", "red"); 
                } 
                else 
                { 
                    this.CheckBoxList1.Items[i].Text =this.CheckBoxList1.Items[i].Text.IndexOf("font") == -1 ? "<font color=‘Black’>" + this.CheckBoxList1.Items[i].Text + "</font>" : this.CheckBoxList1.Items[i].Text.Replace("red", "Black"); 
    
                } 
            } 
        }
    
    
    
    
  • 相关阅读:
    mybatis批量更新策略
    tk.mybatis扩展通用接口
    IDEA入门——jdbc连接和工具类的使用
    tensorflow——3
    再战tensorflow
    tensorflow初学
    Anaconda和TensorFlow安装遇到的坑记录
    《企业应用架构模式》——阅读笔记3
    机器学习十讲——第十讲
    机器学习十讲——第九讲
  • 原文地址:https://www.cnblogs.com/xiaofengfeng/p/1938976.html
Copyright © 2011-2022 走看看