Create an ASP. NET page

Source: Internet
Author: User

How to store our news items according to RSS2.0 specifications, we first create an ASP. NET page, when a user sends a request, it will return the aggregated content of the website. More specifically, we will create an ASP. NET page named rss. aspx, which will return the latest five news items in the Articles database table in the format specified by RSS2.0.

There are several ways to accomplish this, which will be discussed later. But now, we need to do one thing first, that is, we need to get the latest five news items from the database. This can be obtained using the following SQL query statement:

SELECTTOP5ArticleID, Title, Author, Description, DatePublishedFROMArticlesORDERBYDatePublishedDESC

After obtaining the information, we need to convert the information into the corresponding RSS2.0 format aggregate file. The easiest and quickest way to display database data as XML data is to use the Repeater control. To be precise, the Repeater control displays <rss> elements, <channel> elements, and site-related element tags in HeaderTemplate and FooterTemplate templates, and <item> elements in ItemTemplate templates. Below is the HTML section of the ASP. NET page. aspx file:

 
 
  1. <%@Pagelanguage="c#"ContentType="text/xml"Codebehind="rss.aspx.cs" 
  2. AutoEventWireup="false"Inherits="SyndicationDemo.rss"%> 
  3. <asp:Repeateridasp:Repeaterid="rptRSS"runat="server"> 
  4. <HeaderTemplate> 
  5. <rssversionrssversion="2.0"> 
  6. <channel> 
  7. <title>ASP.NETNews!</title> 
  8. <li> 
  1. XML data displayed on the ASP. NET page
  2. What is iframe asp. NET?
  3. ASP. NET lifecycle display
  4. Solve the Problem of ASP. net ajax script errors
  5. ASP. NET Applications

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.