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

📄 grouplistitem.cs

📁 ASP中web自定义控件的使用源码及说明文档
💻 CS
字号:
using System;
using System.ComponentModel;
using System.Web.UI;

namespace Bestcomy.Web.UI.WebControls
{
	/// <summary>
	/// 
	/// </summary>
	public class GroupListItem : System.Web.UI.IStateManager
	{
		private string _text = string.Empty;
		private string _value = string.Empty;
		private bool _selected = false;
		private bool _IsTrackingViewState = false;

		#region constructor
		public GroupListItem() : this(string.Empty, string.Empty)
		{
		}

		public GroupListItem(string text) : this(text, text)
		{
		}

		public GroupListItem(string text, string value)
		{
			_text = text;
			_value = value;
		}
		#endregion

		#region attributes
		public string Text
		{
			get
			{
				if(_text != string.Empty)
					return _text;
				if(_value != string.Empty)
					return _value;
				return string.Empty;
			}
			set
			{
				_text = value;
			}
		}

		public string Value
		{
			get
			{
				if(_value != string.Empty)
					return _value;
				if(_text != string.Empty)
					return _text;
				return string.Empty;
			}
			set
			{
				_value = value;
			}
		}

		public bool Selected
		{
			get
			{
				return _selected;
			}
			set
			{
				_selected = value;
			}
		}
		#endregion

		#region IStateManager members

		void IStateManager.TrackViewState()
		{
			_IsTrackingViewState = true;
		}

		[Browsable(false)]
		bool IStateManager.IsTrackingViewState
		{
			get
			{
				return _IsTrackingViewState;
			}
		}

		object IStateManager.SaveViewState()
		{
			return new Triplet(Text, Value, Selected);
		}

		void IStateManager.LoadViewState(object state)
		{
			if(state!=null && state is Triplet)
			{
				this.Text = (string)((Triplet)state).First;
				this.Value = (string)((Triplet)state).Second;
				this.Selected = (bool)((Triplet)state).Third;
			}
		}

		#endregion
	}
}

⌨️ 快捷键说明

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