Files
Umbraco-CMS/components/editorControls/yesno/yesNo.cs
Shandem f6d0d043b5 DO NOT DOWNLOAD. DOWNLOAT LATEST STABLE FROM RELEASE TAB
Created 4.1.0 branch

[TFS Changeset #55082]
2009-06-19 07:39:16 +00:00

69 lines
1.4 KiB
C#

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
namespace umbraco.editorControls
{
/// <summary>
/// Generates a radiolist of yes and no for boolean fields
/// </summary>
public class yesNo : System.Web.UI.WebControls.CheckBox, interfaces.IDataEditor
{
private interfaces.IData _data;
public yesNo(interfaces.IData Data) {
_data = Data;
}
private String _text;
public Control Editor {
get
{
return this;
}
}
public virtual bool TreatAsRichTextEditor
{
get {return false;}
}
public bool ShowLabel
{
get {return true;}
}
public void Save()
{
string value = "";
if (Checked)
value = "1";
else
value = "0";
_data.Value = value;
}
protected override void OnInit(EventArgs e)
{
base.OnInit (e);
this.Text = ui.Text("yes");
}
/// <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)
{
if (!Page.IsPostBack && _data != null && _data.Value != null)
{
if (_data.Value.ToString() == "1")
this.Checked = true;
}
base.Render(output);
}
}
}