Asp. NET page creation

Source: Internet
Author: User

How we store our news items in accordance with the RSS2.0 specification, we first create a ASP.net page, and when the user makes a request, it returns the content of the site aggregation. Rather, we'll create a asp.net page called rss.aspx, which returns the latest 5 news items from the Articles database table in the RSS2.0 specification format.

There are several ways to do this, which will be mentioned later. But now, the first thing we have to do is to get the latest 5 news items from the database. This can be obtained by using the following SQL query statement:

Selecttop5articleid,title,author,description,datepublishedfromarticlesorderbydatepublisheddesc

Having obtained this information, we need to convert this information into the corresponding RSS2.0 format aggregation file. The simplest and fastest way to display the database data as XML data is to use the Repeater control. To be exact, the Repeater control will display < rss> elements, < channel> elements, and site-related element tags in the HeaderTemplate and FooterTemplate templates. Display < item> elements inside the ItemTemplate template. Here is the HTML section of our ASP.net page (. aspx file):

 
  1. <%@pagelanguage= "C #"ContentType= "Text/xml"codebehind="Rss.aspx.cs"
  2. AutoEventWireup= "false"Inherits= "Syndicationdemo.rss"%>
  3. < Asp:repeaterid Asp:repeaterid= "Rptrss"runat= "Server">
  4. <HeaderTemplate>
  5. < rssversion rssversion="2.0">
  6. <channel>
  7. <title> asp.netnews! </title>
  8. <li>


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.