comboboxbuilder.cs

来自「ASP C#代码实例 适合初学人士学习使用」· CS 代码 · 共 35 行

CS
35
字号
using System;
using System.Web;
using System.Web.UI;

namespace WebCombobox {
	/// <summary>
	/// Summary description for ComboBoxBuilder.
	/// </summary>
	internal class ComboBoxBuilder : ControlBuilder {
		public ComboBoxBuilder(){
			//
			// TODO: Add constructor logic here
			//
		}
		public override bool AllowWhitespaceLiterals() {
			return false;
		} 
		
		public override Type GetChildControlType(string tagName, System.Collections.IDictionary attribs) {
			string szTagName = tagName.ToLower();
			int colon = szTagName.IndexOf(':');
			if ((colon >= 0) && (colon < (szTagName.Length + 1))) {
				// Separate the tagname from the namespace
				szTagName = szTagName.Substring(colon + 1, szTagName.Length - colon - 1);
			}
			if (String.Compare(szTagName, "option", true, System.Globalization.CultureInfo.InvariantCulture) == 0 ||
				String.Compare(szTagName, "listitem", true, System.Globalization.CultureInfo.InvariantCulture) == 0 ) {
				return typeof(System.Web.UI.WebControls.ListItem); 
			}
			// No Type was found, throw an exception
			throw new Exception(String.Format("Invalid child with tagname \"{0}\"", tagName));
		}

	}
}

⌨️ 快捷键说明

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