使用jQuery,CSS,JSON和ASP.NET创建新闻轮换控件
发布时间:2018-08-17 21:35:48 所属栏目:传媒 来源:站长网
导读:副标题#e# 这个新闻轮换控件能在网页上的同一个地方显示几条新闻。新闻被拆开几页,为了放置在一个指定的区域。每一页也能包含一对新闻列表。 通过点击底部的页码,能够在不同的页面之间导航,点击页的每个新闻项,就能查看新闻的详细信息。新闻能像幻灯片
在服务器端,我们像下面这样去实现: Copy to Clipboard![]() { // *** Route to the Page level callback 'handler' this.HandleCallbacks(); } // Callback routing public void HandleCallbacks() { if (string.IsNullOrEmpty(Request.Params["Callback"])) return; // *** We have an action try and match it to a handler switch (Request.Params["Callback"]) { case "fetchAllNews": this.FetchAllNews(); break; } Response.StatusCode = 500; Response.Write("Invalid Callback Method"); Response.End(); } public void FetchAllNews() { List<NewsItem> lsttst = new List<NewsItem>(); lsttst.Add(new NewsItem("Environment of Australia", this.ResolveUrl("~/img/news1.jpg"), this.ResolveUrl("~/img/news1_thumb.jpg"), "Australia has a rich variety of endemic legume species that thrive in nutrient-poor soils because of their symbiosis with rhizobia bacteria and mycorrhizal fungi", DateTime.Now.ToShortDateString())); lsttst.Add(new NewsItem("Economy of Australia", this.ResolveUrl("~/img/news2.jpg"), this.ResolveUrl("~/img/news2_thumb.jpg"), "The Australian dollar is the currency of the Commonwealth of Australia, including Christmas Island, Cocos (Keeling) Islands, and Norfolk Island", DateTime.Now.ToShortDateString())); lsttst.Add(new NewsItem("Demographics of Australia and Immigration to Australia", this.ResolveUrl("~/img/news3.jpg"), this.ResolveUrl("~/img/news3_thumb.jpg"), "Most of the estimated 21.8 million Australians are descended from colonial-era settlers and post-Federation immigrants from Europe", DateTime.Now.ToShortDateString())); lsttst.Add(new NewsItem("Religion in Australia", this.ResolveUrl("~/img/news4.jpg"), this.ResolveUrl("~/img/news4_thumb.jpg"), "Australia has no state religion. In the 2006 census, 64% of Australians were listed as Christian of any denomination, including 26% as Roman Catholic and 19% as Anglican", DateTime.Now.ToShortDateString())); lsttst.Add(new NewsItem("Education in Australia", this.ResolveUrl("~/img/news5.jpg"), this.ResolveUrl("~/img/news5_thumb.jpg"), "School attendance is compulsory throughout Australia. In most Australian States at 5–6 years of age all children receive 11 years of compulsory education", DateTime.Now.ToShortDateString())); Response.ContentType = "application/json; charset=utf-8"; Response.Write(JavaScriptConvert.SerializeObject(lsttst)); Response.End(); } 代码:TopNews.rar 参考原文:http://www.codeproject.com/KB/applications/TopNews.aspx 雅虎新闻轮换控件:http://www.codeproject.com/KB/applications/YahooNewsRotator_.aspx 作者:朱祁林 出处:http://zhuqil.cnblogs.com(编辑:南京站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |