using System;
using System.ComponentModel;
using System.Web.UI;

namespace SK.MemberWeb.Controls
{
	[ToolboxDataAttribute("<{0}:MetaTag runat=server></{0}:MetaTag>")]
	[DefaultPropertyAttribute("TagName")]
	public class MetaTag : Control
	{

		[BindableAttribute(true)]
		[DefaultValueAttribute("Keywords")]
		[DescriptionAttribute("The name of the meta tag")]
		[CategoryAttribute("Behavior")]
		public string MetaTagName
		{
			get
			{
				
				if (base.ViewState["MetaTagName"]==null)
				{
					return String.Empty;
				}
				else
				{
					return base.ViewState["MetaTagName"].ToString();
				}
			}

			set
			{
				base.ViewState["MetaTagName"] = value;
			}
		}

		[DefaultValueAttribute("")]
		[DescriptionAttribute("The content of the meta tag")]
		[BindableAttribute(true)]
		[CategoryAttribute("Behavior")]
		public string Content
		{
			get
			{
				if (base.ViewState["Content"]==null)
				{
					return String.Empty;
				}
				else
				{
					return base.ViewState["Content"].ToString();
				}
			}

			set
			{
				base.ViewState["Content"] = value;
			}
		}

		protected override void Render(HtmlTextWriter output)
		{
			string str = MetaTagName;
			if (MetaTagName.Length == 0)
			{
				throw new InvalidProgramException("The name property of the meta tag must be set.");
			}
			output.AddAttribute(HtmlTextWriterAttribute.Name, str);
			output.AddAttribute("content", Content);
			output.RenderBeginTag(HtmlTextWriterTag.Meta);
			output.RenderEndTag();
		}

		protected override ControlCollection CreateControlCollection()
		{
			return new EmptyControlCollection(this);
		}
	}
}
