您的位置:首页 > 理论基础 > 计算机网络

XmlHttp实现无刷新三联动下拉框

2007-05-26 09:29 369 查看
<HTML>
<HEAD>
<title>XmlHttp实现无刷新三联动下拉框</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">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<INPUT style="Z-INDEX: 102; LEFT: 448px; WIDTH: 56px; POSITION: absolute; TOP: 8px; HEIGHT: 24px"
onclick="getData();" type="button" value="test">
<asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 8px" runat="server"
Width="424px"></asp:TextBox>
<asp:DropDownList id="DropDownList2" runat="server" style="Z-INDEX: 103; LEFT: 176px; POSITION: absolute; TOP: 48px"></asp:DropDownList>
<asp:DropDownList id="DropDownList1" runat="server" style="Z-INDEX: 104; LEFT: 16px; POSITION: absolute; TOP: 48px"></asp:DropDownList>
<asp:DropDownList id="DropDownList3" runat="server" style="Z-INDEX: 105; LEFT: 296px; POSITION: absolute; TOP: 48px"></asp:DropDownList>
</form>
</body>
</HTML>

2.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;
using System.Data.SqlClient;
namespace WebApplication1

3.数据库area1.rar
4.Ajax实现无刷新三联动下拉框

5.源代码下载XmlHttpselect.rar

6.Asp.Net 2.0 中 回发或回调参数无效 的解决方案
回发或回调参数无效。在配置中使用 <pages enableEventValidation="true"/> 或在页面中使用 <%@ Page EnableEventValidation="true" %> 启用了事件验证。出于安全目的,此功能验证回发或回调事件的参数是否来源于最初呈现这些事件的服务器控件。

目前为止遇到的出现情况有两种:
一是Form嵌套,一个页面只能有一个Form,仔细检查代码就可以解决。
二是在下拉菜单中使用javascript 来更改内容(如AJAX),常见于省 市 联动菜单,在事件回发时提示该错误。

该错误只有在 vs 2.0 上才会出现,如果把 enableEventValidation="true" 改成 enableEventValidation="false" 错误是不会出事了但是在代码中确读不到此项的值。

第一种情况的话不能在form 里嵌form
第二种情况的解决办法 就是把 控制改成 Html 的控制,控件带上 runat="server"

如:下面是我的一个解决办法

一个省份和城市的链动效果

<asp:DropDownList ID="DropDownList3" runat="server" onchange="changelocation(DropDownList3.options[DropDownList3.selectedIndex].value)">
</asp:DropDownList>


<select name="DDLcity" id="DDLcity" runat="server">
<option value="0">=请选择=</option>
</select>

然后在 后台 cs代码里用 Request.Form["DDLcity"]; 来接收城市的值。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: