<script language="javascript" type="text/javascript">
function srcollnews() {
var scrollup = new ScrollText("listcontent");
scrollup.LineHeight = 60;
scrollup.Amount = 1;
scrollup.Start();
}
if (document.all) {
window.attachEvent('onload', srcollnews)
}
else {
window.addEventListener('load', srcollnews, false);
}
</script>
<asp:ListView ID="listNews" runat="server" style="top: 0px; left: 0px" >
<LayoutTemplate>
<div id="listcontent">
<asp:PlaceHolder ID="itemPlaceHolder" runat="server"/>
</div>
</LayoutTemplate>
<ItemTemplate>
<div class="listpro">
<a href='<%# Eval("LinkURL") %>'><%# Eval("Title") %></a>
</div>
</ItemTemplate>
</asp:ListView>
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.listNews.DataSource =this.GetSnapshotList();
this.listNews.DataBind();
}
}
public List<SnapshotInfo> GetSnapshotList()
{
List<SnapshotInfo> infoList = new List<SnapshotInfo>();
SPSite site = SPContext.Current.Site;
SPWeb web = site.OpenWeb("NewsCenter");
SPList list = web.GetList(String.Format("{0}/Lists/LoopNews", web.Url));
SPQuery query = new SPQuery();
query.Query = String.Format("<OrderBy><FieldRef Name=\"ID\" Ascending=\"False\" /></OrderBy>");
query.RowLimit = 10;
SPListItemCollection colls = list.GetItems(query);
foreach (SPListItem item in colls)
{
SnapshotInfo info = new SnapshotInfo();
info.ID = item.ID;
info.Title = item["Title"].ToString();
info.LinkURL = UtilityPlus.GetItemString(item["URL"]);
infoList.Add(info);
}
return infoList;
}