Online RSS reader developed based on ASP. NET Ajax technology (Part 1)

Source: Internet
Author: User

1. RSS Technology Overview

RSS is an XML format used to describe and synchronize website content. It has become a popular website content subscription technology. Through this technology, the website can greatly improve the data interaction between the majority of website users and website data.

RSS reading software can be divided into two categories: offline desktop and online. With this tool, users only need to add the RSS URLs they are interested in. Later, the system will automatically update the relevant content. Users only need to wait for the news they are interested in.

There are multiple versions of RSS file formats, including 0.90, 0.91, 0.92, 0.93, 0.94, 1.0, and 2.0. Among them, version 2.0 is the most popular. The following shows the basic format of the simplest 2.0 RSS file:

 
      


example channel

http://example.com/
my example channel


News for September the second
http://example.com/2002/09/01
Other things happened today

News for September the first
http://example.com/2002/09/02



The main nodes of the RSS File Include RSS, channels, and items. The RSS node indicates the standard RSS namespace for execution. The channel node indicates a category in a blog or newsgroup, which is usually translated into a channel. The item node is the main information you want to view, it includes the title of the information, the link address of the information content, and the Publishing Time of the information. For details about the complete RSS file node, visit http://cyber.lay.harvard.edu/blogs/gems/tech/rss2sample.xml.

About robsman's ASP. net rss Toolkit

Obviously, it is time and effort-consuming to manually Parse XML files because there are many versions of RSS files and there are some gaps. Fortunately, we can use the open-source RSS toolkit developed by Microsoft (download URL: http://blogs.msdn.com/dmitryr/) to simplify it.

This toolkit has the following features:

1) RSS data source control-similar to the data source control built in ASP. NET, it also supports binding and supporting templated data binding, and provides it with the required data display;

2) The contents of the remote RSS feed can be cached in the memory or disk;

3) RSS-based URLs generate strong types of objects that are easy to develop and debug for RSS feeds;

4) pairProgramThe corresponding typical operations of the RSS feed generated in.

Next, we will use a specific example to explore how to use this toolkit and develop a simple RSS news reader based on the Microsoft ASP. NET Ajax framework.

Ii. Analysis of Main functions and key technologies of the system

Before the official start of the project, let's take a look at the main functions of the system and the main technologies involved in the development of the system.

(1) Main Functions

An online RSS reader can store your favorite RSS subscriptions in a server-side database so that they can be accessed at any location with an Internet connection. Typically, we can use 1 to roughly describe the engineering process of an RSS reader.

Figure 1: typical Engineering Process of an RSS reader

According to the above, dajaxrssreader will mainly achieve the following objectives:

◆ Add an RSS feed

You can save the 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 the SQL Server database of the remote server.

◆ Display all RSS feeds

This mainly includes two situations: 1. When an application is started, all the channel information stored in the server database should be listed on the browser; 2. When a user Refreshes an RSS feed, all data associated with the feed can be read back from the server and displayed on the client.

◆ Display the details of the selected RSS Feed

When you select a channel, the application should be able to display the corresponding webpage content linked to the channel.

(2) Key Technologies

First, we should follow the well-known three-tier structure principle whenever possible during the development of any typical web application. Figure 2 shows the three-tier architecture of the RSS reader program in this article.

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

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

Figure 3: The sample RSS reader is a snapshot of the design time.

Based on the graph shown above and the functional analysis above, we need to develop the application in this article based on the following key technologies:

1. In the description layer, we need to use ASP. net Ajax client listview control to store and display all RSS channel information, there is also a server-side updatepanel control to encapsulate ASP. net Ajax Control Toolkit control accordion to display the website content associated with the items you selected from the listview. In addition, we also need some CSS skills to modify all related controls. Finally, we introduced the ASP. NET Ajax client validator (validator) to verify the RSS name and URL entered by the user.

2. In the example program in this article, we will mix JavaScript with XML-script Declarative Programming. On the one hand, in the actual development environment, based on ASP. the web applications of the net Ajax framework are usually quite complex; on the other hand, Asp. the net Ajax framework itself is not yet fully mature, so that our building objectives are fully developed based on the XML-script Declarative Programming Method. Although the implementation of some programming is more complex than the XML-script declarative method by using JavaScript (because ASP. net Ajax client provides a very similar to ASP. net), but the advantage of JavaScript is that it can control every aspect of the development process from the server to the client.

3. For data layer Development Based on ASP. NET Ajax applications, a typical implementation mode has been provided in online data. This mode will be used in this example.

Author's note] When debugging the sample program in this article, I was introduced to ASP. net Ajax Control Toolkit control combined with Dmitry robsman ASP.. Net RSS toolkit issues client-to-server communication problems. According to my analysis, we usually cannot implement the rssdatasource (RSS) on the server inside a web service. net Toolkit) is dynamically bound to the accordion control (actually an ASP.. Net Ajax server Extender ). Therefore, in order to overcome this problem, I have to resort to the _ dopostback function to create a connection between the client and the server. This will obviously lead to a problem of refreshing the whole page-this is similar to ASP. net Ajax rules are fundamentally conflicted. Therefore, I have to introduce the ASP. NET Ajax Server Control updatepanel to "enclose" the accordion control to achieve partial update. Of course, the other thing that makes things more complicated is the ASP. NET Ajax client control-listview. From the analysis of the underlying layer, the listview control is far from mature!

Next, let's gradually explore the development process of the entire sample project from the data layer design and development.

Iii. Data Layer Design

(1) Database Design

Start Visual Studio 2005, select "File> New website ...", Select the "ASP. NET Ajax-enabled web site" template, name the project "ajaxrss", select C # As the built-in support language, and click OK. Note that the system will automatically add references to the Assembly Microsoft. Web. Preview. dll and System. Web. Extensions. dll. Of course, you will also notice that scriptmanager, the server control of ASP. NET Ajax command, is automatically added to the default webpage default. aspx.

Right-click the project and select "Add new project ...", Select the template "SQL database" to create an empty database named rssreader. MDF. In this article, we only add a table rssstore in this library (all its fields are shown in table 1 below ). After that, we will 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 good support solution, as shown in this article ). We will not repeat all this here.

Table 1: Structure of table rssstore

Field name

type

description

rss_id

int

table primary key

/ TD>

rss_name

nchar (32)

RSS channel name

/ TD>

rss_url

nchar (64)

RSS channel URI (or URL )

(2) web service design

Next, we will compile a web service that will be called in Ajax mode from the client. In this example, let the service return an array of rssinfo objects (used as the OOP wrapper recorded in the database table rssstore.

Right-click the project and select "Add new project ..." Create a new Web Service mydataservice. asmx. Then open the file bookdataservice. CS and write all the web methods we require-deleterecord, getallrecords, insertrecord, and UpdateRecord. These four methods are similar to the one I previously posted on 51cto.ArticleThe basic consistency involved in this section is not detailed here. Interested readers can also refer to the corresponding source code for analysis.

Next, we will enter the user interface design stage.

Iv. User Interface Layer Design

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

1) Add new RSS feed information;

2) display the RSS feed list;

3) display the content of the specified RSS feed (that is, the content of the website associated with it ).

Figure 3 above shows the user interface for the application design in this article.

In Figure 3 above, an ASP. NET Ajax client control-listview is located in the upper left corner. It is used to store and display the RSS channel list. The lower-end. gif animation (Note: it corresponds to the emptytemplate part of the control listview) is only used to produce a more friendly user experience. The large rectangle area of the animation page (it contains several simple ASP. net Ajax client control) the field corresponds to an HTML Div tag (named "buttonarea"), providing users with New RSS channel information. The right part of the entire web page is an accordion control in ASP. NET Ajax Control Toolkit, which is used to display details of a specified RSS channel. There are several other "mysterious" dots on the page, the ASP. NET Ajax Server Control updatepanel that is surrounded by the accordion control, and the associated updateprogress control, which will be detailed later. Now, you must have noticed the RSS toolkit control-rssdatasource control in the lower-left corner of the page, which is used to provide data sources for the accordion control on the server side (generally, we can only use it from the server at runtime, because it is a server-side data source control. For details about this control, we will introduce it later ). Finally, all controls are surrounded by an HTML table element.

So far, we have finished introducing the data layer and description layer in this software. In the next article, let's move to the logic layer design, the focus 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.