Development of online RSS reader based on ASP.net Ajax technology (last article)

Source: Internet
Author: User
Tags add format functions interface sql net version visual studio

"Note" This article tests the environment: Windows XP Professional Edition +visual Studio 2005+ complete asp.net ajax framework +asp.net RSS Toolkit+sql Server 2005.

Introduction of RSS Technology

RSS is an XML format that describes and synchronizes web content, and has become an increasingly popular technology for Web content subscriptions. Through this technology, the site can greatly improve the vast number of Web site users and the data exchange between the site data.

RSS reading software can be divided into desktop off-line and online-type two categories. With this tool, users only need to add the initial focus of their RSS URL, the system will automatically update the relevant content, users need to observe their own interest in the news.

There are currently several versions of the RSS file format, with 0.90, 0.91, 0.92, 0.93, 0.94, 1.0, and 2.0. Among them, the most popular version is 2.0. The following shows the basic format for the simplest version of the RSS file in 2.0:

<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>Example Channel</title>
<link>http://example.com/</link>
<description>My example channel </description>
<item>
<title>News for September the Second</title>
<link>http://example.com/2002/09/01</link>
<description>other things happened today</description>
</item>
<item>
<title>News for September the First</title>
<link>http://example.com/2002/09/02</link>
</item>
</channel>
</rss>

The main nodes of RSS files are RSS, channel and item. Where the RSS node represents the execution of the RSS standard namespace, the channel node represents a category in a blog or newsgroup, usually translated as a channel; The item node is the primary information that the user wants to see, including the title of the message, the link address of the information content, and the time the information was published. For a complete description of the RSS file, please refer to the URL http://cyber.lay.harvard.edu/blogs/gems/tech/rss2sample.xml.

About Robsman's asp.net RSS Toolkit

Obviously, because the RSS file version is numerous, and there is a certain gap, if the manual parsing XML file is time-consuming and laborious. Fortunately, we can make use of the Open Source RSS Toolkit toolkit (download URL: http://blogs.msdn.com/dmitryr/) developed by Microsoft Corporation to simplify it.

This toolkit has the following features:

1 RSS Data Source Control-it is used in the same way as the ASP.net built-in data source control, it also supports binding and supporting templated data binding, and provides it with the data needed to display;

2 The content of remote RSS feeds can be cached in memory or disk;

3 based on RSS URL address for RSS feed to generate easy to develop debugging of strongly-typed objects;

4 the corresponding typical operation of the RSS feed generated in the program is encapsulated.

Here's a concrete example to explore how to use this toolkit and develop a simple RSS feed reader based on the Microsoft ASP.net AJAX framework.

Second, the main functions of the system and key technology analysis

Before the formal commencement, let's take a look at the main functions of the system and the main technologies involved in developing the system.

(i) Main functions

An online RSS reader can store your favorite RSS feeds in a server-side database for later access to any location with an Internet connection at your convenience. Typically, we can use the following figure to roughly describe an RSS reader's engineering process.

Figure 1: A typical engineering process for an RSS reader

According to the diagram above, our RSS Reader sample Engineering Dajaxrssreader will mainly achieve the following objectives:

Add RSS Channel

Users can save their newly-entered RSS channel and related URL information to the asp.net AJAX client data source control. And of course, they can store all this information in a remote server SQL Server database.

Show All RSS channels

This mainly includes two kinds of situations: 1. When the application first starts, all channel information stored in the server-side database should be able to be listed in the browser-side; 2, when the user refreshes the RSS channel, all the data associated with the channel can be read back from the server and displayed on the client side.

Displays the details of the selected RSS Channel

When a user selects a channel, the application should be able to display a specific page content that is linked to the channel.

(ii) Key technologies

First, in the process of developing any typical Web application, we should follow the well-known three-tier architecture principles as much as possible. Figure 2 of the following figure shows the corresponding three-layer schema sketch for the RSS reader program in this article.

Figure 2: The overall architecture diagram of the RSS reader program in this article

Next, before we formally discuss the key technologies involved, let's take a quick look at the snapshot of the sample program's home page, as shown in Figure 3 below.

Figure 3: Sample RSS reader design time snapshot in this article

Based on the graphics and previous functional analysis shown above, we generally need to develop the applications in this article based on the following key technologies:

1. In the description layer, we need to use the ASP.net AJAX client ListView control to store and display all RSS channel information, and a server-side UpdatePanel control to encapsulate the ASP.net AJAX controls in the diagram above Toolkit control accordion to eventually display the site content associated with the item you selected from ListView. In addition, we need a little CSS technique to decorate all the related controls. Finally, we also introduced the ASP.net AJAX Client verifier (Validator) to validate the user-entered RSS name and URL.

2. In this sample program, we'll mix JavaScript with xml-script declarative programming. On the one hand, Web applications based on ASP.net Ajax frameworks are often quite complex in a real-world development environment, and the ASP.net AJAX framework itself is not yet fully mature to enable our build goals to be developed entirely on the basis of Xml-script declarative programming. Although implementations are relatively more complex to use JavaScript in implementing certain programming than Xml-script declarative methods (because ASP.net Ajax clients provide a very similar asp.net declarative programming approach, but the advantage of JavaScript is that it can be used in every aspect of the control development process from the server to the client side.

3. For data-tier development based on ASP.net AJAX applications, a typical implementation pattern has been provided in the online data, and this example will uphold this pattern.

The author note When debugging the sample program in this article, I was plagued by the introduction of ASP.net AJAX Control Toolkit controls and the problem of client-side communication with the Robsman asp.net RSS toolkit. According to my analysis, in general, we cannot dynamically bind a server-side Rssdatasource (a class in Rss.net toolkit) to a accordion control in a Web service internal implementation (actually a asp.net Ajax server-Side extender). Therefore, in order to overcome this dilemma, I had to turn to the __doPostBack function to create a client-server connection, which obviously raised the issue of a whole-side flush-which conflicted with the ASP.net ajax rules. To do this, I had to introduce the ASP.net Ajax server control UpdatePanel to "surround" the accordion controls for local updating. Of course, the other thing that complicates things further is the asp.net AJAX client control-listview. From the bottom of the analysis, this ListView control is far from mature!

Below, let's explore the entire sample project development process from data-tier design and development.

Third, the data layer design

(i) Database design

Start Visual Studio 2005, select file → new site ..., then select the asp.net ajax-enabled Web site template, name the project "Ajaxrss", and select C # as the built-in support language, and then click OK. Note that the system will automatically include references to assembly Microsoft.Web.Preview.dll and System.Web.Extensions.dll thereafter. Of course, you will also notice that the server control ScriptManager as the asp.net ajax command is automatically added to the default page default.aspx.

Now, right-click the project, select "Add New Item ..." and select template "SQL database" to create an empty database named Rssreader.mdf. In this article application, we only add a table Rssstore to this library (all of its fields are shown in table 1 below). After that, we will also create four stored procedures: Deleterecord,getallrecords,insertrecord and UpdateRecord. These four stored procedures correspond to typical database crud operations (asp.net AJAX client Data binding technology provides a better support scenario, as shown in this article). All of these things we do not repeat here.

Table 1: Table rssstore the corresponding structure

Field name

Type Description
rss_id Int Table PRIMARY Key
Rss_name NCHAR (32) RSS Channel Name
Rss_url NCHAR (64) RSS channel uri (or URL)

Two Web Service Design

Next, we're going to write a Web service that will be invoked from the client in AJAX mode. In the example of this article, we let the service return an array of Rssinfo objects, which are used as OOP wrappers for records in the database table Rssstore.

Now, right-click the project and select "Add New Item ..." To create a new Web service mydataservice.asmx. Then, open the file BookDataService.cs, where you write all the Web methods-deleterecord,getallrecords,insertrecord and UpdateRecord that we require. These four methods are basically consistent with my previous articles published in 51CTO, and I do not repeat them here. Interested readers can also refer to the corresponding source code for analysis.

Below, we will go to the user interface design phase.

Iv. User Interface Layer Design

Based on the general framework described above, we can divide the entire user interface section into three sub sections:

1 Add new RSS channel information;

2 Display the list of RSS channels;

3 Displays the content of the specified RSS channel (that is, the site content associated with it).

Figure 3 above shows the user interface for the design time of this application.

In Figure 3 above, the upper-left corner is a asp.net AJAX client control-listview that stores and displays a list of RSS channels. The. gif animation below it (note: It corresponds to the emptytemplate template portion of the control ListView) is only intended to produce a more user-friendly user experience effect. The larger rectangular area of the animated page (which contains a simple number of simple asp.net AJAX client controls) field corresponds to an HTML div tag (named "Buttonarea") that provides the user with input to the new RSS channel information. The right part of the entire Web page is a accordion control in the ASP.net AJAX controls toolkit that displays the details of the specified RSS channel. There are several other "mysteries" dots on the page with asp.net Ajax server control UpdatePanel and associated updateprogress controls that surround the accordion control, which we'll explain in more detail later. Now, you must have noticed the RSS Toolkit Control-rssdatasource control at the bottom left of the page, which is used to provide a data source for the accordion control from the server side (in general, we can only use it from the server side at run time, Because it is a server-side data source control. The details about this control, we also want to introduce later. Finally, all the controls are surrounded with an HTML TABLE element.

So far, we've covered the data layer and description layer in the software. In the next chapter, let's move on to the design of the logical layer of the entire development process.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.