ASP.NET+JS 制作纵向广告滚动

ASPX页面下代码:

<form id="form1" runat="server">
<DIV id=icefable2>
<%--        <table  border="0" cellpadding="0" cellspacing="0" width="212px" align="center">                   
              <TBODY>
            <tr class="listMenu">
            <td>   --%>
            <asp:DataList ID="leftPicShow" runat="server" Font-Underline="False" Width="212px" class="listMenu">
            <ItemTemplate>
                <tr>
                <td align="center" width="212px"><a target=_blank title='<%#gettitle(Eval("JP_Title").ToString())%>' href=../jpxl_details.aspx?id=<%#Eval("JP_ID") %>><asp:ImageButton ID="ImageButton1" runat=server Width="212" Height="130" Enabled=false ImageUrl='<%#Eval("JP_pic","~/jpxlPIC/{0}")%>' /></a></td>
                </tr>
               
</ItemTemplate>
</asp:DataList>
<%--            </td>
            </tr>
              </TBODY>
       </TABLE>--%></DIV>
                        <SCRIPT language="javascript">
                        marqueesHeight=349;
                        stopscroll=false;
                        with(icefable2)
                        {    style.width=20;
                             style.height=marqueesHeight;  
                             style.overflowX="visible";   
                             style.overflowY="hidden";   
                             noWrap=true;   
                             οnmοuseοver=new Function("stopscroll=true");   
                             οnmοuseοut=new Function("stopscroll=false");  
                        }  
                        preTop=0;
                        currentTop=130;
                        stoptime=0;  
                        icefable2.innerHTML+=icefable2.innerHTML;  
                    function init_srolltext()
                        {  
                        icefable2.scrollTop=0;  
                        setInterval("scrollUp()",80);
                        }
                        init_srolltext();
                    function scrollUp()
                        {  
                          if(stopscroll==true) return;  
                          currentTop+=1;  
                          if(currentTop==130)  
                          {   
                            stoptime+=1;   
                            currentTop-=1;   
                            if(stoptime==130)   
                            {    
                            currentTop=0;    
                            stoptime=0;       
                            }  
                          }  
                          else
                          {     
                          preTop=icefable2.scrollTop;   
                          icefable2.scrollTop+=1;   
                          if(preTop==icefable2.scrollTop)
                          {     
                          icefable2.scrollTop=130;     
                          icefable2.scrollTop+=1;        
                          }  
                          }
                        }               
            </SCRIPT>
                       
</form>

ASPX.CS页面下代码:

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GetData();
        }
    }
    public string gettitle(string s)
    {
        if (s.Length > 11) return s.Substring(0, 10) + "...";
        return s;
    }
    protected void GetData()
    {
        string sql = "SELECT Top 4 * FROM TB_JPXL WHERE (JP_ShowYN = 1) order by JP_ID desc";
        PagedDataSource pds = new PagedDataSource();
        pds.DataSource = DBDS.DB(sql).Tables[0].DefaultView;
        leftPicShow.DataSource = pds;
        leftPicShow.DataBind();
    }

DBDS为新建类库之一:

    public static DataSet DB(string sql)
    {
        SqlDataAdapter dap = new SqlDataAdapter(sql,ConfigurationManager.AppSettings["connstr"]);
        DataSet ds = new DataSet();
        dap.Fill(ds);
        return ds;
    } 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值