As you can see in the previous section, the Readfeed () method is invoked each time a user clicks on the feed. So we can call the Getrsscontent () method in the server-side Web service asynchronously in the Readfeed () method, and pass the ID of the current feed past. Of course, you should also display the update prompt panel for the user before an asynchronous call:
function readFeed(id) {
// 显示更新提示面板。
showProgressBar(true);
// 取得提要的内容。
RssService.GetRssContent(id, onRssContentGot);
}
The code for the callback method Onrsscontentgot () provided when the Getrsscontent () method is invoked is as follows. It hides the update prompt panel and then constructs the contents of the feed using the contententry[data returned by the Web service and displays it to the content area on the right side of the page:
function onRssContentGot(result) {
// 隐藏更新提示面板。
showProgressBar(false);
// 构造提要内容HTML字符串。
var contentBuilder = new Sys.StringBuilder();
for (var index = 0; index < result.length; ++index) {
contentBuilder.append(" contentBuilder.append(result[index].Link); // Link
contentBuilder.append("" target="_blank" >");
contentBuilder.append(result[index].Title); // Title
contentBuilder.append("</a> contentBuilder.append(result[index].Content); //Content
contentBuilder.append("</div> }
// 设置到提要内容元素上。
var content = $get("content");
content.innerHTML = contentBuilder.toString();
}