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

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
T
Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
H
Hackread – Cybersecurity News, Data Breaches, AI and More
I
Intezer
C
Cyber Attacks, Cyber Crime and Cyber Security
The Register - Security
The Register - Security
量子位
Security Latest
Security Latest
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
C
CXSECURITY Database RSS Feed - CXSecurity.com
MyScale Blog
MyScale Blog
J
Java Code Geeks
Apple Machine Learning Research
Apple Machine Learning Research
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
Spread Privacy
Spread Privacy
Jina AI
Jina AI
博客园 - 【当耐特】
P
Palo Alto Networks Blog
Last Week in AI
Last Week in AI
SecWiki News
SecWiki News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
G
GRAHAM CLULEY
宝玉的分享
宝玉的分享
Hacker News - Newest:
Hacker News - Newest: "LLM"
T
The Blog of Author Tim Ferriss
V
Vulnerabilities – Threatpost
有赞技术团队
有赞技术团队
T
Tor Project blog
H
Hacker News: Front Page
A
Arctic Wolf
NISL@THU
NISL@THU
A
About on SuperTechFans
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
V
V2EX
N
News and Events Feed by Topic
Webroot Blog
Webroot Blog
Know Your Adversary
Know Your Adversary
P
Privacy International News Feed
I
InfoQ
D
Docker
L
LINUX DO - 最新话题
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
U
Unit 42

博客园 - 末世纪狂潮

[导入]Pylogs v1.14beta (正式支持Django 1.0) 发布 [导入]Django中动态改变ImageField和FileField中文件的上传路径 [导入]Tech·ED 2008 票到了。。。 [导入]ASP.NET获取客户端IP地址的几点补充[转载] - 末世纪狂潮 - 博客园 [导入]Windows Live Mail不能启动的解决办法 - 末世纪狂潮 [导入]Linux Mint中文语言包 [导入]XPS 1530安装MAC OsX 10.5.2指南 [导入]奥运加油,中国加油 [导入]IE7打不开微软的首页了? [导入]linux下常用格式的压缩与解压方法 [导入]利用PIL生成水印图片或文字 [导入]Pylogs v1.12beta发布 test live write write blog 用C#写一个简单的WINDOWS服务程序 测试tb "百万首页"深度思考 QQ天气预报代码 QQ登录没反应解决方法,及新版QQ的一个BUG 要开始学JAVA了,郁闷中。。。
.NET中实现无刷新客户端联动下拉菜单
末世纪狂潮 · 2006-03-01 · via 博客园 - 末世纪狂潮

.NET中实现无刷新客户端联动下拉菜单 (无刷新) (通过下拉菜单动态显示不同图片也可也该方法实现)
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="CustomManager.company.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
 
<HEAD>
  
<title>WebForm1</title>
  
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
  
<meta content="C#" name="CODE_LANGUAGE">
  
<meta content="JavaScript" name="vs_defaultClientScript">
  
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
  
<LINK href="../css/style.css" type="text/css" rel="stylesheet">
 
</HEAD>
 
<body MS_POSITIONING="GridLayout">
  
<form id="Form1" method="post" runat="server">
   
<asp:dropdownlist id="DropDownList1" style="Z-INDEX: 101; LEFT: 40px; POSITION: absolute; TOP: 168px"
    runat
="server"></asp:dropdownlist>

<!--以下的label中隐藏存放一级栏目和二级栏目对应的内容-->
<asp:label id="Label1" style="display:none;" runat="server">Label</asp:label>


   
<asp:DropDownList id="DropDownList2" style="Z-INDEX: 104; LEFT: 40px; POSITION: absolute; TOP: 264px"
    runat
="server"></asp:DropDownList></form>
<script LANGUAGE="javascript">
//将隐藏的字符串取出来,然后分割到一个数组中去
var str = document.getElementById("Label1").innerText;
arr
=str.split(",");
a
=arr.length
ar
=new Array()
for (i=0;i<a;i++){
  ar[i]
=arr[i].split("-");
}

onecount
=ar.length;


//此处实现联动
function  ld() {
  document.Form1.DropDownList2.length
=0
  lid
=Form1.DropDownList1.value;       
  
for  (i=0;i<onecount;i++)  
    
if  (ar[i][0]  ==  lid) {
   document.Form1.DropDownList2.options.add(
new Option(ar[i][2],  ar[i][1]));    
    }
    
  }
   
}
  
/*换图片的方法
function changeimg()
{
 document.Form1.faceimage.src="images/face/"+document.Form1.userface.value;
}

*/

function showMsg()
{
 alert(document.Form1.DropDownList1.value);
 alert(document.Form1.DropDownList2.value);
}


  
</script>
 
</body>
</HTML>



以下是WebForm1.aspx.cs

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace CustomManager.company
{
 
/// <summary>
 
/// WebForm1 的摘要说明。
 
/// </summary>

 public class WebForm1 : System.Web.UI.Page
 
{
  
protected System.Web.UI.WebControls.DropDownList DropDownList1;
  
protected System.Web.UI.WebControls.Label Label1;
  
protected System.Web.UI.WebControls.DropDownList DropDownList2;
  
static protected DataTable tb1;
 
  
private void Page_Load(object sender, System.EventArgs e)
  
{
   
// 在此处放置用户代码以初始化页面

   
if(!Page.IsPostBack)
   
{
    
   }


//给DropDownList1设置onchange事件
   DropDownList1.Attributes.Add("onchange","ld();");
   
string strConn,strSql;
   System.Data.SqlClient.SqlDataAdapter da;
   

//从数据库中取出一级栏目,绑定到     DropDownList1
strConn = "server=localhost;database=custom;uid=custom;pwd=a;";
   strSql 
= "select * from custom.bigcalling;";
   da 
= new System.Data.SqlClient.SqlDataAdapter(strSql,strConn);
   DataTable tb3 
= new DataTable();
   da.Fill(tb3);

   DropDownList1.DataSource 
= tb3;
   DropDownList1.DataTextField 
= "BIGCALLNAME";
   DropDownList1.DataValueField
= "BIGCALLID";
   DropDownList1.DataBind();

//取出二级栏目数据,存放到一个DataTable()中
   strSql = "select * from custom.smallcalling;";
   da 
= new System.Data.SqlClient.SqlDataAdapter(strSql,strConn);
   tb1 
= new DataTable();
   da.Fill(tb1);


//以下就是将一级和二级菜单的内容,分别以"-"和","隔开
//然后存放到 Label1中,这样客户端就可以通过脚本取得所需要的数据了
   Label1.Text = "";

   
foreach(DataRow row in tb1.Rows)
   
{
    Label1.Text 
= Label1.Text  + row["BIGCALLID"+ "-" +row["SMALLCALLID"+ "-"+row["SMALLCALLNAME"+ ",";

   }


  }


  
Web 窗体设计器生成的代码

  
 }

}