
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;


[ParseChildren(false)]
public partial class MyLabel : System.Web.UI.UserControl
{
	/// <summary>
	/// UserControl.Render override.
	/// </summary>
	protected override void Render(HtmlTextWriter writer)
	{
		writer.Write("<div");
		if (_cssClass != "")
		{
			writer.Write(" class=\"");
			writer.Write(_cssClass);
			writer.Write("\"");
		}
		if (_style != "")
		{
			writer.Write(" style=\"");
			writer.Write(_style);
			writer.Write("\"");
		}
		writer.Write(">");
		writer.Write(_text);
		writer.Write("</div>");
	}

	/// <summary>
	/// UserControl.SaveViewState override.
	/// </summary>
	protected override object SaveViewState()
	{
		System.Collections.Hashtable map = new System.Collections.Hashtable();

		map.Add("Text", _text);
		map.Add("Style", _style);
		map.Add("CssClass", _cssClass);

		return map;
	}

	/// <summary>
	/// UserControl.LoadViewState override.
	/// </summary>
	protected override void LoadViewState(object savedState)
	{
		System.Collections.Hashtable map = savedState as System.Collections.Hashtable;

		if (map == null)
			return;

		_text = map["Text"] as string;
		_style = map["Style"] as string;
		_cssClass = map["CssClass"] as string;
	}

	/// <summary>
	/// UserControl.AddParsedSubObject override.
	/// </summary>
	protected override void AddParsedSubObject(object obj)
	{
		if (obj is LiteralControl)
			_text = (obj as LiteralControl).Text;

		base.AddParsedSubObject(obj);
	}


	/// <summary>
	/// Gets or sets the text displayed by the label.
	/// </summary>
	public string Text
	{
		get { return _text; }
		set { _text = value; }
	}

	/// <summary>
	/// Gets or sets the css clas associated with the label.
	/// </summary>
	public string CssClass
	{
		get { return _cssClass; }
		set { _cssClass = value; }
	}

	/// <summary>
	/// Gets or sets the css style of the label.
	/// </summary>
	public string Style
	{
		get { return _style; }
		set { _style = value; }
	}


	private string _text;
	private string _cssClass;
	private string _style;
}
