61,817
社区成员




<script language="javascript" type="text/javascript">
$(document).ready(function(){
$('#lb_Father').click(function(){
$.ajax({type:'get',url:'SonType.ashx?command=getson',success:function(html){
$('#lb_Son').empty().append(html);
}});
});
});
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ListBox Ajax</title>
<script src="js/jquery.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
$('#lb_Father').click(function(){
$.ajax({type:'get',url:'SonType.ashx?command=getson',success:function(html){
$('#lb_Son').empty().append(html);
}});
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ListBox ID="lb_Father" runat="server" Width="150px">
<asp:ListItem Text="我是一" Value="1"></asp:ListItem>
<asp:ListItem Text="我是二" Value="2"></asp:ListItem>
</asp:ListBox>
<asp:ListBox ID="lb_Son" runat="server" Width="150px"></asp:ListBox>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
</div>
</form>
</body>
</html>
public class SonType : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
if (context.Request.QueryString["command"] != null)
{
string command = context.Request.QueryString["command"].ToString();
if (command == "getson")
{
string items = "";
string item = "";
for (int i = 0; i < 10; i++)
{
item = "<option value=" + (i + 1) + ">item" + (i + 1) + "</option>";
items += item;
}
context.Response.Write(items);
}
}
}
public bool IsReusable {
get {
return false;
}
}
}