日期:2014-05-18  浏览次数:20375 次

求dropdownlist联动无刷新的代码,谢谢啊
求dropdownlist联动无刷新的代码,网上找了试过,都不能用,讲得也不是很清楚,求哪位给我详细的代码,谢谢啊

------解决方案--------------------
1、以前asp的处理方式,使用javascript来处理,不会刷新

2、使用ajax
------解决方案--------------------
用httpXML吧。网上有很多代码,找找吧
------解决方案--------------------
试着用一下回调函数,比较好.
------解决方案--------------------

<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "Default.aspx.cs " Inherits= "_Default " Debug= "true " %>

<!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> Untitled Page </title>

<script language= "javascript " type= "text/javascript ">
function get_RoleValue()
{
var bureauType=document.getElementById( "PossibleTargetBureauTypeDDL ");
//alert(bureauType.value);
_Default.GetRoleValueDataSet(bureauType.value,get_bureauType_Result_CallBack);
}
function get_bureauType_Result_CallBack(response)
{
if (response.value != null)
{
document.all( "PossibleTarGetRoleDDL ").length=1;    
var ds = response.value;
if(ds != null && typeof(ds) == "object " && ds.Tables != null)
{
for(var i=0; i <ds.Tables[0].Rows.length; i++)
{
//alert(ds.Tables[0].Rows.length);
var value=ds.Tables[0].Rows[i].RoleValue;
var text=ds.Tables[0].Rows[i].RoleText;
document.all( "PossibleTarGetRoleDDL ").options.add(new Option(text,value));
}

}
}
return
}

function get_Bureaus()
{
var bureauType=document.getElementById( "PossibleTargetBureauTypeDDL ");
var bureauGrade=document.getElementById( "BureauGradesDDL ");
_Default.GetBureauDataSet(bureauType.value,bureauGrade.value,get_bureaus_Result_CallBack);
}
function get_bureaus_Result_CallBack(response)
{
if (response.value!=null)
{
document.all( "PossibleTargetBureauDDL ").length=1;
var ds = response.value;
if(ds!=null && typeof(ds)== "object " && ds.Tables !=null)
{
//alert(ds.Tables[0].Rows.length);
for(var i=0; i <ds.Tables[0].Rows.length; i++)
{
var bureaucode=ds.Tables[0].Rows[i].BureauCode;
var bureauname=ds.Tables[0].Rows[i].BureauName;
document.all( "PossibleTargetBureauDDL ").options.add(new Option(bureauname,bureaucode));
}

}
}
return
}

function get_Users()
{
var bureauType=document.getElementById( "PossibleTargetBureauTypeDDL ");
var bureau=document.getElementById( "PossibleTargetBureauDDL ");
var roleValue=document.getElementById( "PossibleTarGetRoleDDL ");
_Default.GetUserDataSet(bureau.value,roleValue.value,bureauType.value,get_users_Result_CallBack);
}

function get_users_Result_CallBack(r