可输入的DropDownList控件
1
<%@ Page language="c#" Codebehind="ddlWriteControl.aspx.cs" AutoEventWireup="false" Inherits="WebDemo.ddlWriteControl" %>
2
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
3
<HTML>
4
<HEAD>
5
<title>ddlWriteControl</title>
6
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
7
<meta name="CODE_LANGUAGE" Content="C#">
8
<meta name="vs_defaultClientScript" content="JavaScript">
9
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
10
<style> #div1 { Z-INDEX: 1; LEFT: 250px; WIDTH: 216px; CLIP: rect(3px 280px 21px 110px); POSITION: absolute; TOP: 89px; HEIGHT: 72px } #div2 { LEFT: 250px; WIDTH: 95px; POSITION: absolute; TOP: 89px; HEIGHT: 18px; 2: } </style>
11
</HEAD>
12
<body MS_POSITIONING="GridLayout">
13
<script language="javascript">
14
function AddOption()
15
{
16
var val = document.getElementById("txtValue").value;
17
var option = document.getElementById("ddl");
18
19
if(val == "")
20
{
21
alert("请输入项值");
22
return;
23
}
24
if(option.length > 0)
25
{
26
for(var i=0;i<option.length;i++)
27
{
28
if(option.options[i].value == val)
29
{
30
alert("该值已存在!");
31
return;
32
}
33
}
34
}
35
36
var option_val = new Option(val,val);
37
38
option.add(option_val);
39
option.selectedIndex = option.options.length-1;
40
41
}
42
</script>
43
<form id="Form1" method="post" runat="server">
44
<div id="div1" style="Z-INDEX: 101; WIDTH: 128px; HEIGHT: 72px">
45
<asp:DropDownList id="ddl" onchange="document.getElementById('txtValue').value = this.value" runat="server"
46
Width="127">
47
<asp:ListItem Value="aaa1">aaa1</asp:ListItem>
48
<asp:ListItem Value="bbb2">bbb2</asp:ListItem>
49
<asp:ListItem Value="ccc3">ccc3</asp:ListItem>
50
</asp:DropDownList>
51
</div>
52
<FONT face="宋体"></FONT>
53
<div id="div2">
54
<asp:TextBox id="txtValue" style="PADDING-LEFT:2px;PADDING-TOP:2px" runat="server" Width="127"></asp:TextBox>
55
<input type="button" value="OK" id="btn" onclick="AddOption();">
56
</div>
57
58
</form>
59
</body>
60
</HTML>
61![](/Images/OutliningIndicators/None.gif)
如果有问题请与我联系。
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/None.gif)
4
![](/Images/OutliningIndicators/None.gif)
5
![](/Images/OutliningIndicators/None.gif)
6
![](/Images/OutliningIndicators/None.gif)
7
![](/Images/OutliningIndicators/None.gif)
8
![](/Images/OutliningIndicators/None.gif)
9
![](/Images/OutliningIndicators/None.gif)
10
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
11
![](/Images/OutliningIndicators/None.gif)
12
![](/Images/OutliningIndicators/None.gif)
13
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
14
![](/Images/OutliningIndicators/InBlock.gif)
15
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
16
![](/Images/OutliningIndicators/InBlock.gif)
17
![](/Images/OutliningIndicators/InBlock.gif)
18
![](/Images/OutliningIndicators/InBlock.gif)
19
![](/Images/OutliningIndicators/InBlock.gif)
20
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
21
![](/Images/OutliningIndicators/InBlock.gif)
22
![](/Images/OutliningIndicators/InBlock.gif)
23
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
24
![](/Images/OutliningIndicators/InBlock.gif)
25
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
26
![](/Images/OutliningIndicators/InBlock.gif)
27
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
28
![](/Images/OutliningIndicators/InBlock.gif)
29
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
30
![](/Images/OutliningIndicators/InBlock.gif)
31
![](/Images/OutliningIndicators/InBlock.gif)
32
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
33
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
34
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
35
![](/Images/OutliningIndicators/InBlock.gif)
36
![](/Images/OutliningIndicators/InBlock.gif)
37
![](/Images/OutliningIndicators/InBlock.gif)
38
![](/Images/OutliningIndicators/InBlock.gif)
39
![](/Images/OutliningIndicators/InBlock.gif)
40
![](/Images/OutliningIndicators/InBlock.gif)
41
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
42
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
43
![](/Images/OutliningIndicators/None.gif)
44
![](/Images/OutliningIndicators/None.gif)
45
![](/Images/OutliningIndicators/None.gif)
46
![](/Images/OutliningIndicators/None.gif)
47
![](/Images/OutliningIndicators/None.gif)
48
![](/Images/OutliningIndicators/None.gif)
49
![](/Images/OutliningIndicators/None.gif)
50
![](/Images/OutliningIndicators/None.gif)
51
![](/Images/OutliningIndicators/None.gif)
52
![](/Images/OutliningIndicators/None.gif)
53
![](/Images/OutliningIndicators/None.gif)
54
![](/Images/OutliningIndicators/None.gif)
55
![](/Images/OutliningIndicators/None.gif)
56
![](/Images/OutliningIndicators/None.gif)
57
![](/Images/OutliningIndicators/None.gif)
58
![](/Images/OutliningIndicators/None.gif)
59
![](/Images/OutliningIndicators/None.gif)
60
![](/Images/OutliningIndicators/None.gif)
61
![](/Images/OutliningIndicators/None.gif)