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![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
<
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![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
<
script
language
="javascript"
>
14
function AddOption()
15![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
16
var val = document.getElementById("txtValue").value;
17
var option = document.getElementById("ddl");
18
19
if(val == "")
20![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
21
alert("请输入项值");
22
return;
23
}
24
if(option.length > 0)
25![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
26
for(var i=0;i<option.length;i++)
27![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
28
if(option.options[i].value == val)
29![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
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
如果有问题请与我联系。
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](/Images/OutliningIndicators/ContractedBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
2
![None.gif](/Images/OutliningIndicators/None.gif)
3
![None.gif](/Images/OutliningIndicators/None.gif)
4
![None.gif](/Images/OutliningIndicators/None.gif)
5
![None.gif](/Images/OutliningIndicators/None.gif)
6
![None.gif](/Images/OutliningIndicators/None.gif)
7
![None.gif](/Images/OutliningIndicators/None.gif)
8
![None.gif](/Images/OutliningIndicators/None.gif)
9
![None.gif](/Images/OutliningIndicators/None.gif)
10
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](/Images/OutliningIndicators/ContractedBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
11
![None.gif](/Images/OutliningIndicators/None.gif)
12
![None.gif](/Images/OutliningIndicators/None.gif)
13
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](/Images/OutliningIndicators/ContractedBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
14
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
15
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](/Images/OutliningIndicators/ContractedSubBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
16
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
17
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
18
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
19
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
20
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](/Images/OutliningIndicators/ContractedSubBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
21
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
22
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
23
![ExpandedSubBlockEnd.gif](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
24
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
25
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](/Images/OutliningIndicators/ContractedSubBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
26
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
27
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](/Images/OutliningIndicators/ContractedSubBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
28
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
29
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](/Images/OutliningIndicators/ContractedSubBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
30
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
31
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
32
![ExpandedSubBlockEnd.gif](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
33
![ExpandedSubBlockEnd.gif](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
34
![ExpandedSubBlockEnd.gif](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
35
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
36
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
37
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
38
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
39
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
40
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
41
![ExpandedSubBlockEnd.gif](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
42
![ExpandedBlockEnd.gif](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
43
![None.gif](/Images/OutliningIndicators/None.gif)
44
![None.gif](/Images/OutliningIndicators/None.gif)
45
![None.gif](/Images/OutliningIndicators/None.gif)
46
![None.gif](/Images/OutliningIndicators/None.gif)
47
![None.gif](/Images/OutliningIndicators/None.gif)
48
![None.gif](/Images/OutliningIndicators/None.gif)
49
![None.gif](/Images/OutliningIndicators/None.gif)
50
![None.gif](/Images/OutliningIndicators/None.gif)
51
![None.gif](/Images/OutliningIndicators/None.gif)
52
![None.gif](/Images/OutliningIndicators/None.gif)
53
![None.gif](/Images/OutliningIndicators/None.gif)
54
![None.gif](/Images/OutliningIndicators/None.gif)
55
![None.gif](/Images/OutliningIndicators/None.gif)
56
![None.gif](/Images/OutliningIndicators/None.gif)
57
![None.gif](/Images/OutliningIndicators/None.gif)
58
![None.gif](/Images/OutliningIndicators/None.gif)
59
![None.gif](/Images/OutliningIndicators/None.gif)
60
![None.gif](/Images/OutliningIndicators/None.gif)
61
![None.gif](/Images/OutliningIndicators/None.gif)