<script type="text/javascript">google_ad_client = "pub-2048279401139630";google_ad_slot = "8856771542";google_ad_width = 728;google_ad_height = 90;document.write("<s"+"cript type='text/javascript' s"+"rc='http://pagead2.googlesyndication.com/pagead/show_ads"+"."+"js'></scr"+"ipt>");</script>
首先,新建一个web窗体,然后在工具栏拖拽两个listbox控件到页面上,如下面的示例:
<%
...
@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApp.WebForm1"
%>
<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
>
<
HTML
>
<
HEAD
>
<
title
>
WebForm1
</
title
>
<
meta
name
="GENERATOR"
Content
="Microsoft Visual Studio .NET 7.1"
>
<
meta
name
="CODE_LANGUAGE"
Content
="C#"
>
<
meta
name
="vs_defaultClientScript"
content
="JavaScript"
>
<
meta
name
="vs_targetSchema"
content
="http://schemas.microsoft.com/intellisense/ie5"
>
</
HEAD
>
<
body
MS_POSITIONING
="GridLayout"
>
<
form
id
="Form1"
method
="post"
runat
="server"
>
<
FONT
face
="宋体"
>
<
asp:ListBox
id
="ListBox1"
style
="Z-INDEX: 101; LEFT: 352px; POSITION: absolute; TOP: 272px"
runat
="server"
AutoPostBack
="True"
>
<
asp:ListItem
Value
首先,新建一个web窗体,然后在工具栏拖拽两个listbox控件到页面上,如下面的示例:
<%
...
@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApp.WebForm1"
%>
<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
>
<
HTML
>
<
HEAD
>
<
title
>
WebForm1
</
title
>
<
meta
name
="GENERATOR"
Content
="Microsoft Visual Studio .NET 7.1"
>
<
meta
name
="CODE_LANGUAGE"
Content
="C#"
>
<
meta
name
="vs_defaultClientScript"
content
="JavaScript"
>
<
meta
name
="vs_targetSchema"
content
="http://schemas.microsoft.com/intellisense/ie5"
>
</
HEAD
>
<
body
MS_POSITIONING
="GridLayout"
>
<
form
id
="Form1"
method
="post"
runat
="server"
>
<
FONT
face
="宋体"
>
<
asp:ListBox
id
="ListBox1"
style
="Z-INDEX: 101; LEFT: 352px; POSITION: absolute; TOP: 272px"
runat
="server"
AutoPostBack
="True"
>
<
asp:ListItem
Value
ASP.NET实现Listbox联动效果

本文介绍了在ASP.NET WebForm中如何创建两个联动的ListBox控件。通过在第一个ListBox的SelectedIndexChanged事件中添加代码,当选择其中一个项时,动态加载第二个ListBox的内容。详细展示了页面布局、后台代码实现及事件处理方法。
最低0.47元/天 解锁文章
4355

被折叠的 条评论
为什么被折叠?



