marquee 滚动新闻-多条显示

<marquee style= height:240px; direction= "down"  οnmοuseοver= "this.stop()" scrollamount="2" οnmοuseοut="this.start()">
    <asp:Repeater ID="Repeater1" runat="server">
            <ItemTemplate>
            <table width="100%">
            <tr>
            <td  style="padding-left: 2px;line-height:12px" align="left">
             &nbsp;&nbsp;•&nbsp;&nbsp;<a href='gzdt3.aspx?CatID = <%# Eval("new_id")%>'>

<%# webSiteCS.strFormat(Eval("new_title").ToString(), 5)></a>
            </td>

<td>

    <%# DataBinder.Eval(Container.DataItem, "new_dateTime" , "{0:MM-dd}")%>

               </td>
            </tr>
            </table> 
            </ItemTemplate>
     </asp:Repeater>
 </marquee>

 

 

///后台绑定

        ///通知公告
        ///
        dbConn dbC = new dbConn();
        ///测试通过类连接Access
        Repeater1.DataSource = dbC.GetOleDataSet("select * from new", "new");
        Repeater1.DataBind();

 

类文件

    /// <summary>
    /// 格式化字符串长度,超出部分显示省略号,区分汉字跟字母。汉字2个字节,字母数字一个字节
    /// </summary>
    /// <param name="str">处理前的字符串</param>
    /// <param name="n">保留字符串的长度</param>
    /// <returns>处理后的字符串</returns>
    public static string strFormat(string str, int n)
    {
        string temp = string.Empty;

        if (System.Text.Encoding.Default.GetByteCount(str) <= n)//如果长度比需要的长度n小,返回原字符串
        {
            return str;
        }
        else
        {
            int t = 0;
            char[] q = str.ToCharArray();
            for (int i = 0; i < q.Length && t < n; i++)
            {
                if ((int)q[i] >= 0x4E00 && (int)q[i] <= 0x9FA5)//是否汉字
                {
                    temp += q[i];
                    t += 2;
                }
                else
                {
                    temp += q[i];
                    t++;
                }
            }
            return (temp + "...");
        }
    }

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值