一个简单的2级连动(实际都写烂了,做项目顺便写了一个,可能还有些不完善)
2007-06-06 10:27
501 查看
//作者:崔宏宇
//时间:2007-06-06
//说明:用AjaxPro.2.dll框架
Web.Config中配置
<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<appSettings/>
<connectionStrings>
</connectionStrings>
<system.web>
<httpRuntime maxRequestLength="10240" executionTimeout="600"/>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true"/>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows"/>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
<httpHandlers>
<add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
</httpHandlers>
</system.web>
<location path="ajaxpro">
<system.web>
<httpHandlers>
<add verb="*" path="*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/>
</httpHandlers>
<!--
If you need to have Ajax.NET Professional methods running on the
login page you may have to enable your own authorization configuration
here.
-->
<!--
<authorization>
<deny users="?"/>
</authorization>
-->
</system.web>
</location>
</configuration>
前台代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Example.aspx.cs" Inherits="Example" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script language="javascript">
function Getsting()
{
debugger;
var DropDownList1= document.getElementById("DropDownList1");
var DropDownList2= document.getElementById("DropDownList2");
var ExampleDT=Example.MyLight(DropDownList1.value);
//删除DropDownList2
DropDownList2.options.length=0;
for(var i = 0; i < ExampleDT.value.Rows.length; i++)
{
DropDownList2.options.add(new Option(ExampleDT.value.Rows[i]["one"],ExampleDT.value.Rows[i]["two"]));
DropDownList2.selectedIndex=0;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server" onchange="Getsting()">
<asp:ListItem Value="1">第一</asp:ListItem>
<asp:ListItem Value="2">第二</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList>
</div>
</form>
</body>
</html>
后台代码:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Example : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(Example));
}
[AjaxPro.AjaxMethod]
public DataTable MyLight(string Mycondition)
{
DataTable dt = new DataTable();
dt.Columns.Add("one");//添加一列,想加几列再自己加
dt.Columns.Add("two");
DataRow dr;
if (Mycondition == "1")
{
for (int i = 0; i < 10; i++)//每列添多少行,条件自己加
{
dr = dt.NewRow();
dr["one"] = "" + i + "第一列";
dr["two"] = "" + i + "第二列";
dt.Rows.Add(dr);//添加一行
}
}
else if (Mycondition == "2")
{
for (int i = 0; i < 10; i++)//每列添多少行,条件自己加
{
dr = dt.NewRow();
dr["one"] = "" + i + "换第一列";
dr["two"] = "" + i + "换第二列";
dt.Rows.Add(dr);//添加一行
}
}
return dt;
}
}
//时间:2007-06-06
//说明:用AjaxPro.2.dll框架
Web.Config中配置
<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<appSettings/>
<connectionStrings>
</connectionStrings>
<system.web>
<httpRuntime maxRequestLength="10240" executionTimeout="600"/>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true"/>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows"/>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
<httpHandlers>
<add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
</httpHandlers>
</system.web>
<location path="ajaxpro">
<system.web>
<httpHandlers>
<add verb="*" path="*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/>
</httpHandlers>
<!--
If you need to have Ajax.NET Professional methods running on the
login page you may have to enable your own authorization configuration
here.
-->
<!--
<authorization>
<deny users="?"/>
</authorization>
-->
</system.web>
</location>
</configuration>
前台代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Example.aspx.cs" Inherits="Example" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script language="javascript">
function Getsting()
{
debugger;
var DropDownList1= document.getElementById("DropDownList1");
var DropDownList2= document.getElementById("DropDownList2");
var ExampleDT=Example.MyLight(DropDownList1.value);
//删除DropDownList2
DropDownList2.options.length=0;
for(var i = 0; i < ExampleDT.value.Rows.length; i++)
{
DropDownList2.options.add(new Option(ExampleDT.value.Rows[i]["one"],ExampleDT.value.Rows[i]["two"]));
DropDownList2.selectedIndex=0;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server" onchange="Getsting()">
<asp:ListItem Value="1">第一</asp:ListItem>
<asp:ListItem Value="2">第二</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList>
</div>
</form>
</body>
</html>
后台代码:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Example : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(Example));
}
[AjaxPro.AjaxMethod]
public DataTable MyLight(string Mycondition)
{
DataTable dt = new DataTable();
dt.Columns.Add("one");//添加一列,想加几列再自己加
dt.Columns.Add("two");
DataRow dr;
if (Mycondition == "1")
{
for (int i = 0; i < 10; i++)//每列添多少行,条件自己加
{
dr = dt.NewRow();
dr["one"] = "" + i + "第一列";
dr["two"] = "" + i + "第二列";
dt.Rows.Add(dr);//添加一行
}
}
else if (Mycondition == "2")
{
for (int i = 0; i < 10; i++)//每列添多少行,条件自己加
{
dr = dt.NewRow();
dr["one"] = "" + i + "换第一列";
dr["two"] = "" + i + "换第二列";
dt.Rows.Add(dr);//添加一行
}
}
return dt;
}
}
相关文章推荐
- Session用法案例 -->实现简单购物车功能(实际项目可能不会这么使用)
- 最近在写导出excel表格的代码,发现网上大部分代码都是导出简单格式的excel,所以自己顺便就写了一个导出复杂表格的工具类,有些代码是借鉴网友的,同时也谢谢分享代码的朋友们.
- 第十五周项目五:简单电子词典····暂时先这样吧!有些缺陷,以后再回来完善······
- 一个简单单片机项目的一些想法
- 如何让一个简单的maven项目支持one-jar 做成一个jar fatjar
- abap--一个简单类浏览器的代码(等有空继续完善)
- Maven构建一个简单的Java项目
- 一个简单的ibatis.net架构(包含项目模板代码下载)
- 2、Maven在MyEclipse的集成,并建立一个简单的Maven项目
- 在一个软件开发项目中进行实际日程安排的十二点提示(ZT)
- 在一个软件开发项目中进行实际日程安排的十二点提示(转)
- [VB.NET源码]一个实际的商业项目
- ubuntu下使用code::blocks编译运行一个简单的gtk+2.0项目
- SSM做一个简单的网上商城-搭建项目
- 用idea和weblogic简单搭建一个web项目
- 使用Team City如何创建一个简单的项目
- 拦截器在实际项目中(商城)的简单使用
- 开始一个React项目(一)一个最简单的webpack配置
- 2013级Java第1周(春)项目——一个简单的考勤签到程序