您的位置:首页 > 运维架构

ajax实现无刷新两级联动DropDownList

2007-10-21 14:46 501 查看
本文来自小山blog:

http://singlepine.cnblogs.com/articles/257954.html

里面是三级联动,有数据库文件可下栽.

我只是将三级更改为两级,使用SQL SERVER数据库而已.

我的截图如下:

using System;

using System.Data;

using System.Data.SqlClient;

namespace MyAjaxSample

3.HTML代码:

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

<HTML>

<HEAD>

<title>FourAjaxSample</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">

</HEAD>

<body MS_POSITIONING="GridLayout">

<form id="Form1" method="post" runat="server">

<h3>Ajax实现两级联动</h3>

<TABLE class="border" id="border" style="Z-INDEX: 101; LEFT: 16px; WIDTH: 289px; POSITION: absolute; TOP: 48px; HEIGHT: 79px"

borderColor="#95b0d9" cellSpacing="0" cellPadding="0" width="289" align="center" bgColor="#ffffff"

border="1">

<TR>

<TD style="WIDTH: 130px; HEIGHT: 27px" bgColor="#d8e7f6">

<asp:label id="Lab_province" runat="server">省(直辖市)</asp:label></TD>

<TD style="HEIGHT: 27px">

<asp:dropdownlist id="DropDownList1" runat="server" onchange="cityResult();"></asp:dropdownlist></TD>

</TR>

<TR>

<TD style="WIDTH: 130px; HEIGHT: 24px" bgColor="#d8e7f6">

<asp:Label id="Lab_City" runat="server">城市</asp:Label></TD>

<TD style="HEIGHT: 24px">

<asp:DropDownList id="DropDownList2" runat="server" onchange="areaResult();"></asp:DropDownList></TD>

</TR>

<TR>

<TD style="WIDTH: 130px" bgColor="#d8e7f6">你的最后选择是:

</TD>

<TD>

<asp:TextBox id="TextBox1" runat="server"></asp:TextBox></TD>

</TR>

</TABLE>

</form>

</body>

</HTML>

4 .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 MyAjaxSample

5.web.config

<appSettings>

<!-- SQL数据库连接 -->

<add key="ConnectionString" value="Data Source=localhost;User Id=sa;Password=zhangzs;Initial Catalog=mytest;"/>

</appSettings>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: