using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CMS.ExtendedControls;
using CMS.GlobalHelper;
namespace CMS.Ecommerce
{
///
/// TextBoxWithLabel, inherited from System.Web.UI.WebControls.TextBox.
///
[ToolboxItem(false)]
public class TextBoxWithLabel : CMSTextBox
{
private string mLabelCssClass = string.Empty;
private bool mLabelFirst = false;
///
/// CSS class for label.
///
public string LabelCssClass
{
get
{
return mLabelCssClass;
}
set
{
mLabelCssClass = value ?? string.Empty;
}
}
///
/// Label text.
///
public string LabelText
{
get
{
return ValidationHelper.GetString(ViewState["LabelText"], string.Empty);
}
set
{
ViewState["LabelText"] = value ?? string.Empty;
}
}
///
/// Indicates if label has to be placed before text box.
///
public bool LabelFirst
{
get
{
return mLabelFirst;
}
set
{
mLabelFirst = value;
}
}
protected override void Render(HtmlTextWriter writer)
{
// Render base text box when label goes to the end
if (!LabelFirst)
{
base.Render(writer);
}
string attrs = "";
// Append css class attribute
if (!string.IsNullOrEmpty(LabelCssClass))
{
attrs += string.Format("class=\"{0}\"", LabelCssClass);
}
// Render label
writer.Write(string.Format("{0}", LabelText, attrs));
// Render base text box ad the end
if (LabelFirst)
{
base.Render(writer);
}
}
}
}