xmlnewsfeed.cs

来自「ASP.NET服务器控件高级编程电子书」· CS 代码 · 共 83 行

CS
83
字号
using System;
using System.Xml;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Data;

namespace XMLNewsFeed
{
	/// <summary>
	/// Summary description for WebCustomControl1.
	/// </summary>
	[DefaultProperty("Text"),
		ToolboxData("<{0}:XMLNewsFeed runat=server></{0}:XMLNewsFeed>")]
	public class XMLNewsFeed: System.Web.UI.WebControls.WebControl
	{
		private string _text;
		private System.Data.DataSet  _xmldataset = 
			new System.Data.DataSet();
		private string _xmlsource;

		[Bindable(true),
		Category("Data"),
		DefaultValue("")]
		public string XMLSource
		{
			set
			{
				try
				{
					_xmlsource = value;
				}
				catch (Exception e)
				{
					_text = "Error unable to set property [XMLSource] to that value<br>[" + e.Message + "]";
				}
			}
		}

		[Bindable(true),
		Category("Data"),
		DefaultValue("")]
		public System.Data.DataSet XMLDataSet
		{
			get
			{
				return _xmldataset;
			}
		}

		[Bindable(true),
		Category("Appearance"),
		DefaultValue("")]
		public string Text
		{
			get
			{
				return _text;
			}

			set
			{
				_text = value;
			}
		}

		/// <summary>
		/// Render this control to the output parameter specified.
		/// </summary>
		/// <param name="output"> The HTML writer to write out to </param>
		protected override void Render(HtmlTextWriter output)
		{
			output.Write(Text);
		}

		public void Populate()
		{
			//TODO Change this to only load after the skip XML statement
			_xmldataset.ReadXml(_xmlsource);
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?