Listing 1

<%@ Page Language="C#" %>

<%@ Register Assembly="Samples.WebParts" Namespace="Samples.WebParts" TagPrefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>My Website Portal</title>
</head>
<body>
    <h1>Web Parts Demonstration Page</h1>
    <form runat="server" id="form2">
        <asp:WebPartManager ID="WebPartManager1" runat="server">
        </asp:WebPartManager>
        <br />
        <table cellspacing="0" cellpadding="0" border="0">
            <tr>
            <td valign="top">
                <asp:WebPartZone id="SidebarZone" runat="server" headertext="Sidebar">
                    <zonetemplate>
                        <cc1:SimpleWebPartSample ID="SimpleWebPartSample1" runat="server" Title="Top News Stories" />
                    <uc1:WebUserControl id="searchPart" runat="server" title="Search" />
                    </zonetemplate>
                </asp:WebPartZone>
            </td>
            <td valign="top">
                <asp:Webpartzone id="MainZone" runat="server" headertext="Main">
                    <zonetemplate>
                        <asp:label id="contentPart" runat="server" title="Content">
                              <h2>Welcome to My Home Page</h2>
                              <p>Use links to visit my favorite sites!</p>
                        </asp:label>
                    </zonetemplate>
                </asp:Webpartzone>
            </td>
            <td valign="top"></td>
            </tr>
        </table>
    </form>

   
</body>
</html>

Listing 2

        protected override void RenderContents(HtmlTextWriter output)
        {

            //fetch the top news stories RSS feed
            XmlDocument doc = new XmlDocument();
            XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
            nsmgr.AddNamespace("d", "");
            nsmgr.AddNamespace("media", "http://search.yahoo.com/mrss/");

            doc.Load(@"http://feeds.reuters.com/reuters/USVideoTopNews?format=xml");

            //search for the news item nodes in the feed
            XmlNodeList nodes = doc.SelectNodes("d:rss/d:channel/d:item", nsmgr);
            if (nodes != null)
            {

                output.AddStyleAttribute(HtmlTextWriterStyle.Overflow, "auto");
                output.AddStyleAttribute(HtmlTextWriterStyle.Width, this.Width.ToString());
                output.AddStyleAttribute(HtmlTextWriterStyle.Height, this.Height.ToString());
                output.RenderBeginTag(HtmlTextWriterTag.Div); //open host

                //loop through each news item and add content to the control
                foreach (XmlNode node in nodes)
                {

                    output.AddStyleAttribute(HtmlTextWriterStyle.Margin, "5px");
                    output.RenderBeginTag(HtmlTextWriterTag.Div); //open video

                    output.AddStyleAttribute(HtmlTextWriterStyle.FontFamily, "Verdana");
                    output.AddStyleAttribute(HtmlTextWriterStyle.FontSize, "14pt");
                    output.AddStyleAttribute(HtmlTextWriterStyle.FontWeight, "bold");
                    output.AddStyleAttribute("clear", "both");
                    output.RenderBeginTag(HtmlTextWriterTag.Div); //open title
                    output.Write(node.SelectSingleNode("d:title", nsmgr).InnerText);
                    output.RenderEndTag(); //close title

                    output.AddStyleAttribute(HtmlTextWriterStyle.FontFamily, "Arial");
                    output.AddStyleAttribute(HtmlTextWriterStyle.FontSize, "Small");
                    output.RenderBeginTag(HtmlTextWriterTag.Div); //open content

                    
                    output.AddStyleAttribute(HtmlTextWriterStyle.Height, "90px");
                    output.AddStyleAttribute(HtmlTextWriterStyle.Width, "120px");
                    output.AddStyleAttribute("float", "right");
                    output.AddAttribute(HtmlTextWriterAttribute.Src,
					 node.SelectSingleNode("media:group/media:content/media:thumbnail",
					  nsmgr).Attributes["url"].Value);
                    output.AddAttribute(HtmlTextWriterAttribute.Alt, "");
                    output.RenderBeginTag(HtmlTextWriterTag.Img);
                    output.RenderEndTag();

                    output.Write(node.SelectSingleNode("d:description", nsmgr).InnerText);

                    output.RenderEndTag(); //close content

                    output.RenderEndTag(); //close video
                }

                output.RenderEndTag(); //close host
            }
        }