• 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"); 
    
                } 
            } 
        }
    
    
    
    
  • 相关阅读:
    dispatch_semaphore
    dispatch_set_target_queue
    iOS charles支持https抓包
    ios8 毛玻璃效果
    工程里配置.xconfig文件
    线程安全的nsmutabledictionary(读weex代码)
    关于信号量以及多线程的代码
    dispatch_set_target_queue测试
    dyld: Library not loaded问题解决
    iOS图片上加标签或者水印
  • 原文地址:https://www.cnblogs.com/xiaofengfeng/p/1938976.html
Copyright © 2020-2023  润新知