You can find this code in the GetNewsItems method in Listing 8-17. In the source
code included in this book, the StockNews.cs code file includes the ???old way??? to do this using
an XPathNavigator for comparison purposes. The full code listing for both the server control
and its related web form are in Listings 8-17, 8-18, and 8-19.
Listing 8-17. StockNews Control Class File
using System;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Linq;
using System.Xml.Linq;
408 CHAPTER 8 ?– I NTEGRAT ING CLI ENT-SI D E SCRIPT
namespace ControlsBook2Lib.Ch08
{
[ToolboxData("<{0}:StockNews runat=server>{0}:StockNews>"),
DefaultProperty("Symbols")]
public class StockNews : CompositeDataBoundControl, ICallbackEventHandler
{
protected DropDownList list = new DropDownList();
protected HtmlGenericControl div;
private List
items;
[Browsable(false)]
public virtual ListItemCollection Symbols
{
get
{
EnsureChildControls();
return list.Items;
}
}
protected override int CreateChildControls(System.Collections.IEnumerable
dataSource, bool dataBinding)
{
int count = 0;
if (dataSource != null)
{
LiteralControl txt = new LiteralControl("Stock Symbol:");
Controls.
Pages:
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528