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;
}