使用Xml数据源在客户端重新加载数据列表

时间:2013-03-14 06:21:32

标签: javascript jquery asp.net

你好我想通过使用jquery或javscript在常规时间间隔后在客户端重新加载Datalist,这样我就可以获得最新的RSS新闻源了,这是我的代码

<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="http://www.example.com/category/test/feed/"
   XPath="rss/channel/item"></asp:XmlDataSource>
<asp:DataList ID="dlRss" runat="server" DataSourceID="XmlDataSource1">
   <ItemTemplate>
      <label style="color: #222222; float: left; font-size: 16px; margin-top: 5px; width: 190px;">
      <%#  XPath("title")%></label>
      <label style="color: #444444; display: inline-block; font-size: 11px; margin-bottom: 5px;
         width: 190px;">
      <%# Convert.ToDateTime(XPath("pubDate")).ToShortDateString() + " @" + Convert.ToDateTime(XPath("pubDate")).ToShortTimeString()%></label>
      <label style="color: #444444; display: inline-block; font-size: 13px; width: 190px;">
      <%#XPath("description").ToString().Length <= 200 ? XPath("description") : XPath("description").ToString().Substring(0,200) + "...<a href='" + XPath("link").ToString() + "' target='_blank'>more</a>"%></label>
      <br />
   </ItemTemplate>
</asp:DataList>

1 个答案:

答案 0 :(得分:1)

您无法在客户端设置DataSource 但是,您可以做的是在特定时间间隔之后reload您的页面。
否则你将不得不使用http处理程序与jtemplate和jquery。

以下是一些可能对您有帮助的链接
http://johnnycoder.com/blog/2008/12/18/jtemplates-with-jquery-ajax-and-json/
http://www.dotnetcurry.com/ShowArticle.aspx?ID=573