在dropDownList中实现既能输入一个新值又能实现下拉选的代码
发布时间:2016-12-29 来源:查字典编辑
摘要:aspx:复制代码代码如下:
aspx:
复制代码 代码如下:
<div id="selDiv"><%--left:279px; top:167px"--%>
<asp:DropDownList ID="workerno_list" runat="server" Width="110px" ></asp:DropDownList>
</div>
<asp:TextBox ID="workerno_value" runat="server" Font-Size="10" Width="93px" MaxLength ="50" Height="22px"></asp:TextBox>
<script>
function addTxtTanto(va)
{
document.getElementById("workerno_value").value=va;
document.getElementById("workerno_value").select();
}
</script>
aspx.cs:
复制代码 代码如下:
page_load()
{
if (!IsPostBack)
{
workerno_list.Attributes["onchange"] = "addTxtTanto(this.options[selectedIndex].innerText)";
}
}