⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 checkbox.cs

📁 不错的人事管理系统
💻 CS
字号:
using System;

namespace System.Web.UI.WebControls
{
	/// <summary>
	/// Summary description for CheckBox.
	/// </summary>
	public class CheckBox : WebControl, 
		System.Web.UI.IPostBackDataHandler
	{
		private static object EventCheckedChanged;

		static CheckBox() 
		{
			EventCheckedChanged = new Object();
		}

		protected virtual void OnCheckedChanged(EventArgs e) 
		{
			EventHandler local0;

			local0 = (EventHandler) this.Events[CheckBox.EventCheckedChanged];
			if (local0 != null)
				local0.Invoke(this, e);
		}

		protected virtual void OnPreRender(EventArgs e) 
		{
			if (this.Page != null && this.Enabled) 
			{
				this.Page.RegisterRequiresPostBack(this);
				if (this.AutoPostBack)
					this.Page.RegisterPostBackScript();
			}
			if (!(this.SaveCheckedViewState))
				this.ViewState.SetItemDirty("Checked", false);
		}

		protected override void Render(System.Web.UI.HtmlTextWriter writer) 
		{
			bool local0;
			Style local1;
			string local2;
			System.Web.UI.AttributeCollection local3;
			string local4;
			string local5;
			string local6;

			if (this.Page != null)
				this.Page.VerifyRenderingInServerForm(this);
			local0 = false;
			if (this.ControlStyleCreated) 
			{
				local1 = this.ControlStyle;
				if (!(local1.IsEmpty)) 
				{
					local1.AddAttributesToRender(writer, this);
					local0 = true;
				}
			}
			if (!(this.Enabled)) 
			{
				writer.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Disabled, "disabled");
				local0 = true;
			}
			local2 = this.ToolTip;
			if (local2.Length > 0) 
			{
				writer.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Title, local2);
				local0 = true;
			}
			if (this.Attributes.Count != 0) 
			{
				local3 = this.Attributes;
				local4 = local3["value"];
				if (local4 != null)
					local3.Remove("value");
				if (local3.Count != 0) 
				{
					local3.AddAttributes(writer);
					local0 = true;
				}
				if (local4 != null)
					local3["value"] = local4;
			}
			if (local0)
				writer.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Span);
			local5 = this.Text;
			local6 = this.ClientID;
			if (local5.Length != 0) 
			{
				if (this.TextAlign == TextAlign.Left) 
				{
					this.RenderLabel(writer, local5, local6);
					this.RenderInputTag(writer, local6);
					goto i0;
				}
				this.RenderInputTag(writer, local6);
				this.RenderLabel(writer, local5, local6);
			}
			else
				this.RenderInputTag(writer, local6);
			i0: if (local0)
					writer.RenderEndTag();
		}

		protected internal virtual void RenderInputTag(System.Web.UI.HtmlTextWriter writer, string clientID) 
		{
			string local0;
			int local1;

			writer.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Id, clientID);
			writer.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Type, "checkbox");
			writer.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Name, this.UniqueID);
			if (this.Checked)
				writer.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Checked, "checked");
			if (this.AutoPostBack) 
			{
				writer.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Onclick, this.Page.GetPostBackClientEvent(this, ""));
				writer.AddAttribute("language", "javascript");
			}
			local0 = this.AccessKey;
			if (local0.Length > 0)
				writer.AddAttribute(0, local0);
			local1 = this.TabIndex;
			if (local1 != 0)
				writer.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Tabindex, local1.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
			writer.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Input);
			writer.RenderEndTag();
		}

		private void RenderLabel(System.Web.UI.HtmlTextWriter writer, string text, string clientID) 
		{
			writer.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Id, clientID);
			writer.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Label);
			writer.Write(text);
			writer.RenderEndTag();
		}

		bool System.Web.UI.IPostBackDataHandler.LoadPostData(string postDataKey, 
			System.Collections.Specialized.NameValueCollection postCollection) 
		{
			string local0;
			bool local1;
			bool local2;

			local0 = postCollection[postDataKey];
			
			local1 = (local0 != null) ? local0.Length > 0 : false;
			local2 = (local1 != this.Checked);
			this.Checked = local1;
			return local2;
		}

		
		void System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent() 
		{
			this.OnCheckedChanged(System.EventArgs.Empty);
		}

		public event System.EventHandler CheckedChanged
		{
			add
			{
				this.Events.AddHandler(EventCheckedChanged, value);
			}
			remove
			{
				this.Events.RemoveHandler(EventCheckedChanged, value);
			}
		}

		public virtual bool AutoPostBack
		{
			get
			{
				object local0;

				local0 = this.ViewState["AutoPostBack"];
				if (local0 != null)
				{
					return (bool) local0;
				}

				return false;
			}
			set
			{
				this.ViewState["AutoPostBack"] = value;
			}
		}

		public virtual bool Checked
		{
			get
			{
				object local0;

				local0 = this.ViewState["Checked"];
				if (local0 != null)
				{
					return (bool) local0;
				}

				return false;
			}
			set
			{
				this.ViewState["Checked"] = value;
			}
		}

		private bool SaveCheckedViewState
		{
			get
			{
				Type local0;

				if ((this.Events[CheckBox.EventCheckedChanged] != null) || !(this.Enabled))
					return true;
				local0 = this.GetType();
				if (local0 == typeof(CheckBox) || local0 == typeof(RadioButton))
					return false;
				return true;
			}
		}

		public virtual string Text
		{
			get
			{
				object local0;

				local0 = this.ViewState["Text"];
				if (local0 != null)
				{
					return (string) local0;
				}

				return string.Empty;
			}
			set
			{
				this.ViewState["Text"] = value;
			}
		}

		public virtual TextAlign TextAlign
		{
			get
			{
				object local0;

				local0 = this.ViewState["TextAlign"];
				if (local0 != null)
				{
					return (TextAlign) local0;
				}

				return TextAlign.Right;
			}
			set
			{
				if ((int)value < 1 || (int)value > 2)
					throw new ArgumentOutOfRangeException("value");

				this.ViewState["TextAlign"] = value;
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -