use dhtml
http://webfx.eae.net/dhtml/combobox/combobox.htm
http://webfx.eae.net/dhtml/combobox/combo_demo.htm
http://webfx.eae.net/dhtml/combobox/combobox.htm
http://webfx.eae.net/dhtml/combobox/combo_demo.htm
解决方案 »
- 一个全屏的IE,即没有菜单栏,工具栏和地址,请问如何实现?
- asp.net配置环境中怎么配置asp?
- 高分求助一条sql语句
- 为什么总是数据更新了页面不更新,急~~~~~~~~~~~~
- 关于 GridView ASP.NET2.0 在线急等 高手请进 SqlDataSource1.UpdateCommand
- C#如何调用dll实现对硬件的操作
- 后台 .CS文件中的一个 string C_ID 如何做为参数值为前台aspx中的一个超链接id带上此参数?
- reflector可以看到源代码吗?
- ASPNET是一个什么样的账户
- 求教ASP.NET页面控件问题
- 项目转移到其他机器上打不开了
- B/S结构的CRM系统,欢迎大家下载使用!
http://www.metabuilders.com/Tools/ComboBox.aspx
using System.Collections;
using System.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;using JI0.Common;
using JI0.Web;#endregion[
assembly:TagPrefix("JI0.Web.Controls","bigo")
]
namespace JI0.Web.Controls {
[
DefaultProperty("Value"),
ToolboxData("<{0}:MyComboBox runat=server />")
]
public class MyComboBox : Control, INamingContainer {
ListBox listBox = new ListBox();
RegularExpressionValidator regexVal = new RegularExpressionValidator();
TextBox textBox = new TextBox(); ICollection dataSource = new int[] {2322,2,3};
int width = 132;
int maxLength = 50;
bool required = false; string errorMessage = "请注意格式。";
string regularExpression = @".*"; [
Bindable(true),
Category("Appearance"),
DefaultValue(50),
]
public int MaxLength {
get{
return maxLength;
} set{
maxLength = value;
}
} [
Bindable(true),
Category("Appearance"),
DefaultValue(@".*"), ]
public string RegularExpression {
get{
return regularExpression;
} set{
regularExpression = value;
}
} [
Bindable(true),
Category("Appearance"),
DefaultValue(false)
]
public bool Required{
get{
return required;
} set{
required = value;
}
}
[
Bindable(true),
Category("Appearance"),
DefaultValue("请注意格式。"), ]
public ICollection DataSource {
get{
return dataSource;
} set{
dataSource = value;
}
}
[
Bindable(true),
Category("Appearance"),
DefaultValue("请注意格式。"), ]
public string ErrorMessage {
get{
return errorMessage;
} set{
errorMessage = value;
}
} [
Bindable(true),
Category("Appearance"),
DefaultValue(""), ]
public string Value {
get{
return this.textBox.Text;
} set{
this.textBox.Text = value;
}
}
[
Bindable(true),
Category("Appearance"),
DefaultValue(50),
Description("样式属性(宽度)width:50")
]
public int Width {
get{
return width;
} set{
width = value;
}
}
protected override void CreateChildControls() { Controls.Add(new LiteralControl("<div>"));
Controls.Add(textBox);
Controls.Add(listBox);
textBox.ID = "txt";
textBox.MaxLength = maxLength;
textBox.Attributes["style"] = "width:" + width; listBox.ID = "slt";
listBox.Attributes["style"] = "position:absolute; visibility:hidden;width:" + (width + 20);
listBox.DataSource = dataSource;
listBox.DataBind();
listBox.Rows = (listBox.Items.Count > 10 ? 10 : listBox.Items.Count);
listBox.Attributes["onBlur"] = "this.style.visibility='hidden'";
listBox.Attributes["onChange"] = "document.all['" + textBox.UniqueID +
"'].value = this.options[ this.options.selectedIndex ].text;"; string button = "<input value=▼ type=button onclick=\"___MyComboBox_Click('"
+ listBox.UniqueID + "')\">";
Controls.AddAt(2, new LiteralControl(button)); regexVal.ErrorMessage = errorMessage;
regexVal.ValidationExpression = regularExpression;
regexVal.ControlToValidate = textBox.ID; if (required) { RequiredFieldValidator reqVal = new RequiredFieldValidator();
reqVal.ErrorMessage = " **";
reqVal.IsValid = false;
// reqVal.ForeColor = System.Drawing.Color.Black;
reqVal.ControlToValidate = textBox.ID;
Controls.Add(reqVal);
} Controls.Add(regexVal); Controls.Add(new LiteralControl("<br>"));
Controls.Add(listBox);
Controls.Add(new LiteralControl("</div>")); string script = Html.TAG_START_SCRIPT + @"
function ___MyComboBox_Click(selectId) {
var ___MyCombox_Select = document.all[selectId];
___MyCombox_Select.style.visibility = 'visible';
___MyCombox_Select.focus();
}" +
Html.TAG_END_SCRIPT; if (!this.Page.IsClientScriptBlockRegistered("MyComboBox")) this.Page.RegisterClientScriptBlock("MyComboBox", script);
}
}
}
给分了,呵呵!