请问谁有DropDownList做的联动下拉菜单,要没有网页刷新的。

wxr9999 2008-07-16 07:09:55
RT
...全文
119 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
Coco孙 2008-07-18
  • 打赏
  • 举报
回复
。。
lfywy 2008-07-18
  • 打赏
  • 举报
回复
jcrjia的方法不错,测试无误!
lfywy 2008-07-18
  • 打赏
  • 举报
回复
搞定了,这个JS<script src="js/jquery.js" type="text/javascript"></script>去网上下一个就OK了!
加上这个就没有错误了!剩下的就是SonType.ashx?command=getson改变getson值,根据这个在ashx里加载需要的东西,这个很简单了!
DemonAngle 2008-07-18
  • 打赏
  • 举报
回复
只能说明楼主比较懒啊
lfywy 2008-07-18
  • 打赏
  • 举报
回复
jcrjia
用了你的方法,弹出缺少对象!
$(document).ready(function(){
$('#lb_Father').click(function(){
$.ajax({type:'get',url:'SonType.ashx?command=getson',success:function(html){
$('#lb_Son').empty().append(html);
}});
});
});
wxg22526451 2008-07-18
  • 打赏
  • 举报
回复
http://blog.csdn.net/wxg22526451/archive/2008/04/24/2323244.aspx
kwh050101 2008-07-18
  • 打赏
  • 举报
回复
这东西 网上一大堆
jcrjia 2008-07-16
  • 打赏
  • 举报
回复

<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是服务器响应发回的数据
jcrjia 2008-07-16
  • 打赏
  • 举报
回复
发个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.ashx

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;
}
}

}
beijin2008 2008-07-16
  • 打赏
  • 举报
回复
简单实例
http://www.code-123.com/html/20087151126431451966.html
初吻给了烟 2008-07-16
  • 打赏
  • 举报
回复
唉,当初做这个用javascript来做,
后来就AJAX的updatepane,拖控件,拖控件,拖控件,拖控件,完事。
xs8577 2008-07-16
  • 打赏
  • 举报
回复
唉,当初做这个用AjaxPro来做,做完之后发现BUG,怎么都搞不定
一气之下就直接上AJAX.NET,updatepane,拖控件,拖控件,拖控件,拖控件,完事。

62,243

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧