//------------------------------------------------------------------------------
//
// Copyright (c) www.AspxBoy.com All rights reserved.
//
//------------------------------------------------------------------------------
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace HBZ
{
///
/// A Asynchronous AutoPostback Checkbox Control
///
[DefaultEvent("CheckedChanged")]
[ControlValueProperty("Checked")]
[DefaultProperty("Text")]
public class AsynchronousCheckBox : WebControl, INamingContainer, ICallbackEventHandler
{
#region Delegates
///
/// The delegate for the checked changed event
///
///
///
public delegate void CheckedChangedEventHander(object sender, CheckChangedEventArgs e);
#endregion
#region Events
private static readonly object eventCheckedChanged;
///
/// The checked changed event.
///
public event CheckedChangedEventHander CheckedChanged
{
add
{
Events.AddHandler(eventCheckedChanged, value);
}
remove
{
Events.RemoveHandler(eventCheckedChanged, value);
}
}
#endregion
#region Constructors
///
/// Static Constructor
///
static AsynchronousCheckBox()
{
eventCheckedChanged = new object();
}
///
/// Constructor
///
public AsynchronousCheckBox()
: base(HtmlTextWriterTag.Input)
{
}
#endregion
#region Properties
///
/// Gets or sets a value indicating whether the Lable Text
///
[Description("Gets or sets a value indicating whether the Lable Text")]
public virtual string Text
{
get
{
return (string)ViewState["Text"];
}
set
{
this.ViewState["Text"] = value;
}
}
///
/// Gets or sets a value indicating whether the 'Client CallBack Script Name'
///
[Description("Gets or sets a value indicating whether the 'Client CallBack Script function Name'")]
public string ClientCallBackScript
{
get
{
object o = ViewState["ClientCallBackScript"];
return o == null ? "null" : o.ToString();
}
set
{
ViewState["ClientCallBackScript"] = value;
}
}
///
/// Gets or sets a value indicating whether the checkbox 's checked
///
[Description("Gets or sets a value indicating whether the checkbox 's checked")]
public bool Checked
{
get
{
object o = ViewState["Checked"];
return o == null ? false : (bool)o;
}
set
{
ViewState["Checked"] = value;
}
}
///
/// Gets or sets a value indicating whether the Text 's cssClass
///
[Description("Gets or sets a value indicating whether the Text 's cssClass")]
public string TextCss
{
get
{
return (string)ViewState["TextCss"];
}
set
{
ViewState["TextCss"] = value;
}
}
///
/// Gets or sets a value indicating whether the Label 's position
///
public virtual TextAlign TextAlign
{
get
{
object o = ViewState["TextAlign"];
if (o != null)
{
return (TextAlign)o;
}
return TextAlign.Right;
}
set
{
if ((value TextAlign.Right))
{
throw new ArgumentOutOfRangeException("value");
}
ViewState["TextAlign"] = value;
}
}
#endregion
#region Render Meghods
///
///
///
///
protected override void Render(HtmlTextWriter writer)
{
if (TextAlign == TextAlign.Left)
{
RenderLabel(writer);
base.Render(writer);
}
else
{
base.Render(writer);
RenderLabel(writer);
}
}
///
/// Render Label
///
///
private void RenderLabel(HtmlTextWriter writer)
{
if (string.IsNullOrEmpty(Text))
{
return;
}
writer.Write(" http://www.aspxboy.com/private/5504/default.aspx