惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
Forbes - Security
Forbes - Security
Blog — PlanetScale
Blog — PlanetScale
P
Proofpoint News Feed
Apple Machine Learning Research
Apple Machine Learning Research
Google DeepMind News
Google DeepMind News
MyScale Blog
MyScale Blog
GbyAI
GbyAI
B
Blog RSS Feed
S
SegmentFault 最新的问题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
小众软件
小众软件
The Last Watchdog
The Last Watchdog
W
WeLiveSecurity
Webroot Blog
Webroot Blog
S
Security @ Cisco Blogs
Hugging Face - Blog
Hugging Face - Blog
Microsoft Security Blog
Microsoft Security Blog
月光博客
月光博客
博客园 - 聂微东
F
Fortinet All Blogs
H
Hacker News: Front Page
A
About on SuperTechFans
Application and Cybersecurity Blog
Application and Cybersecurity Blog
C
Check Point Blog
V
V2EX
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Y
Y Combinator Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
N
News | PayPal Newsroom
Cisco Talos Blog
Cisco Talos Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
The Cloudflare Blog
P
Privacy & Cybersecurity Law Blog
N
Netflix TechBlog - Medium
C
CXSECURITY Database RSS Feed - CXSecurity.com
Recorded Future
Recorded Future
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
大猫的无限游戏
大猫的无限游戏
美团技术团队
Security Latest
Security Latest
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
I
InfoQ
Recent Announcements
Recent Announcements
The GitHub Blog
The GitHub Blog
Google Online Security Blog
Google Online Security Blog
T
The Exploit Database - CXSecurity.com

博客园 - 冷火

Lucene.Net学习 Argotic Syndication Framework生成RSS - 冷火 Confirm GridView Deletes with the ModalPopupExtender 如何在C#中实现图片缩放 [ASP.NET] 限制上传文件类型的两种方法 asp.net采集 在C#怎用一条正则表达式验证用逗号隔开的email地址 关于LumiSoft.Net.POP3.Client接收邮件例子(包括附件) dhtmlXTreeprofessional asp.net导出xml文件 - 冷火 - 博客园 DateDiff Datagridview下一行下一行 GridView控件修改、删除示例(修改含有DropDownList控件) - 冷火 - 博客园 局域网QQ第三版(V1.4) 非常好的菜单效果(Accordion风格) 静功解决失眠的问题 ASP.NET中文验证码详解 log4net Config Examples 对XAML进行编辑的辅助类(XamlHelper)
asp.net+JSON+AJAX(基于prototype1.4)做无刷新的2级DropDownList - 冷火 - 博客园
冷火 · 2008-10-18 · via 博客园 - 冷火

JSON的数据格式:{"xx":"xx1","yy":[{"yy1":"yyy1"},{"yy2":"yyy2"}]}

后台部分:(合成JSON数据格式)

//这是获取根目录
public string getRootTree()
{

using(SqlDataReader dr=SqlHelper.ExecuteReader(conn,System.Data.CommandType.Text,"select * from MMenu where MParentID=0"))
{
sb.Append("{""region"":[");
while(dr.Read())
{
sb.Append("{""");
sb.Append("MID");
sb.Append(""":""");
sb.Append(dr["MID"].ToString());
sb.Append(""",""");
sb.Append("MName");
sb.Append(""":""");
sb.Append(dr["MName"].ToString());
sb.Append(""",""");
sb.Append("MParentID");
sb.Append(""":""");
sb.Append(dr["MParentID"].ToString());
sb.Append("""},");
}
sb.Append("]");
return sb.ToString().Substring(0,sb.ToString().Length-2)+"]}";
}

//根据ID获取下级的数据

public string getSubTree(int MID)
{
using(SqlDataReader dr=SqlHelper.ExecuteReader(conn,System.Data.CommandType.Text,"select * from MMenu where MParentID="+MID))
{
sb.Append("{""region"":[");
while(dr.Read())
{
sb.Append("{""");
sb.Append("MID");
sb.Append(""":""");
sb.Append(dr["MID"].ToString());
sb.Append(""",""");
sb.Append("MName");
sb.Append(""":""");
sb.Append(dr["MName"].ToString());
sb.Append(""",""");
sb.Append("MParentID");
sb.Append(""":""");
sb.Append(dr["MParentID"].ToString());
sb.Append("""},");
}
sb.Append("]");
return sb.ToString().Substring(0,sb.ToString().Length-2)+"]}";
}
}

前台部分:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<html>
<head>
<title>select</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">
<script src=js/prototype-1.4.0.js></script>
<script>
function getJSON()
{
var myoptions={
parameters:"",
method:"get",
onSuccess:function(res){
var myData=eval("("+res.responseText+")");
myData.region.each(function(xx){
$("root").options.add(new Option(xx.MName,xx.MID));
}
);

}
}
new Ajax.Request("jsonSelect.aspx?action=root&s"+Math.random(),myoptions);
}

function getSub(id)
{
var myoptions={
parameters:"subID="+id,
method:"get",
onSuccess:function(res){
var myData=eval("("+res.responseText+")");
$("sub").options.length=1;
myData.region.each(function(xx){

$("sub").options.add(new Option(xx.MName,xx.MID));
}
);
}
}
new Ajax.Request("jsonSelect.aspx?action=sub&s"+Math.random(),myoptions);
}
</script>
</head>
<body onload=getJSON()>

<form id="Form1" method="post" runat="server">
<select name="a" id="root" onChange="getSub(this.value)">
<option value="" selected>-----请选择类别-----</option>

</select>
<select name="a" id="sub" onChange="getSub(this.value)">
<option value="" selected>-----请选择类别-----</option>

</select>
</form>

</body>
</html>