请问谁有DropDownList做的联动下拉菜单,要没有网页刷新的。 RT 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 唉,当初做这个用AjaxPro来做,做完之后发现BUG,怎么都搞不定一气之下就直接上AJAX.NET,updatepane,拖控件,拖控件,拖控件,拖控件,完事。 唉,当初做这个用javascript来做,后来就AJAX的updatepane,拖控件,拖控件,拖控件,拖控件,完事。 简单实例http://www.code-123.com/html/20087151126431451966.html http://www.code-123.com/html/20087151126431451966.html 发个ListBox的 自己看 不过用了JQuery<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>SonType.ashxpublic 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; } }} <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>还是说说$(document).ready();当DOM加载完成后,执行其中的函数$('#lb_Father').click(fn) 获取id为 lb_Father的DOM元素.click(fn) 单击事件$等于Jquery对象$.ajax() 这是jquery的AJAX实现,简化了AJAX的操作,type请求方式,url请求地址,success请求成功后回调的方法.empty()清空元素的子元素..append()在此元素追加内容最后function(html)中的html是服务器响应发回的数据 http://blog.csdn.net/wxg22526451/archive/2008/04/24/2323244.aspx jcrjia用了你的方法,弹出缺少对象!$(document).ready(function(){ $('#lb_Father').click(function(){ $.ajax({type:'get',url:'SonType.ashx?command=getson',success:function(html){ $('#lb_Son').empty().append(html); }}); }); }); 搞定了,这个JS<script src="js/jquery.js" type="text/javascript"></script>去网上下一个就OK了!加上这个就没有错误了!剩下的就是SonType.ashx?command=getson改变getson值,根据这个在ashx里加载需要的东西,这个很简单了! jcrjia的方法不错,测试无误! 十万火急!asp.net中如何读取Resource资源文件 高手们来看看啊!! 关于jmail配置的简单问题,在线等 InitialData用法 如何将未完成的网页先输出一些到updatepanel 我想删除一链接库文件DLL,但它正被另一进程使用,怎样才可以停止该进程然后删除库文件DLL(系统是win2003) 谁有成功安装asp.net forums 2.0 Alpha版本!!给我一份,最好是汉化了的!!! 帮个忙各位! 请教调用webservice实例的问题 关于Web.config的问题 请问谁懂UDDI 关于StringBuilder 转为string[]数组.
一气之下就直接上AJAX.NET,updatepane,拖控件,拖控件,拖控件,拖控件,完事。
后来就AJAX的updatepane,拖控件,拖控件,拖控件,拖控件,完事。
http://www.code-123.com/html/20087151126431451966.html
<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>SonType.ashxpublic 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;
}
}}
<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>
还是说说
$(document).ready();当DOM加载完成后,执行其中的函数
$('#lb_Father').click(fn) 获取id为 lb_Father的DOM元素
.click(fn) 单击事件
$等于Jquery对象
$.ajax() 这是jquery的AJAX实现,简化了AJAX的操作,type请求方式,url请求地址,success请求成功后回调的方法
.empty()清空元素的子元素.
.append()在此元素追加内容
最后function(html)中的html是服务器响应发回的数据
用了你的方法,弹出缺少对象!
$(document).ready(function(){
$('#lb_Father').click(function(){
$.ajax({type:'get',url:'SonType.ashx?command=getson',success:function(html){
$('#lb_Son').empty().append(html);
}});
});
});
加上这个就没有错误了!剩下的就是SonType.ashx?command=getson改变getson值,根据这个在ashx里加载需要的东西,这个很简单了!