【Vegas原创】Ajax实现无刷新三联动
2006-10-13 18:25
302 查看
1.html代码:
<SCRIPT language="javascript">
//部别------------------------------
function excclassResult()
{
var excclass=document.getElementById("exc_dept");
AjaxMethod.GetexcclassList(excclass.value,get_excclass_Result_CallBack);
}
function get_excclass_Result_CallBack(response)
{
if (response.value != null)
{
//debugger;
document.all("exc_class").length=0;
var ds = response.value;
//alert (ds.Tables[0].Rows[0].escclass);
if(ds != null && typeof(ds) == "object" && ds.Tables != null)
{
for(var i=0; i<ds.Tables[0].Rows.length; i++)
{
var name=ds.Tables[0].Rows[i].escclass;
var id=ds.Tables[0].Rows[i].escclassid;
document.all("exc_class").options.add(new Option(name,id));
}
}
}
return
}
//站别----------------------------------------
function exczbResult()
{
//var a=document.all("exc_class").options[document.all("exc_class").SelectedIndex].Value;
//alert (a);
var exczb=document.getElementById("exc_class");
//alert(exczb.value);
//var exczb=document.all("exc_dept");
//alert (exczb.value);
AjaxMethod.GetexczbList(exczb.value,get_exczb_Result_CallBack);
}
function get_exczb_Result_CallBack(response)
{
//alert (response.value)
if (response.value != null)
{
document.all("exc_zb").length=0;
var ds = response.value;
if(ds != null && typeof(ds) == "object" && ds.Tables != null)
{
for(var i=0; i<ds.Tables[0].Rows.length; i++)
{
var name=ds.Tables[0].Rows[i].exczb;
var id=ds.Tables[0].Rows[i].exczbID;
document.all("exc_zb").options.add(new Option(name,id));
}
}
}
return
}
function getData()
{
var excdept=document.getElementById("exc_dept");
var pindex = excdept.selectedIndex;
var pValue = excdept.options[pindex].value;
var pText = excdept.options[pindex].text;
var excclass=document.getElementById("exc_class");
var cindex = excclass.selectedIndex;
var cValue = excclass.options[cindex].value;
var cText = excclass.options[cindex].text;
var exczb=document.getElementById("exc_zb");
var aindex = exczb.selectedIndex;
var aValue = exczb.options[aindex].value;
var aText = exczb.options[aindex].text;
}
</SCRIPT>
<tr>
<td>发现厂别</td>
<td>
<asp:dropdownlist id="Dropdownlist1" runat="server"></asp:dropdownlist>
</td>
<td>事业部别</td>
<td>
<asp:dropdownlist id="Dropdownlist2" runat="server"></asp:dropdownlist>
</td>
</tr>
<tr>
<td>站别名称</td>
<td colSpan="3" >
<tr>
<td width="137" rowSpan="3">
<asp:listbox id="Listbox1" runat="server" SelectionMode="Multiple"></asp:listbox>
</td>
2.cs代码
Ajax.Utility.RegisterTypeForAjax(typeof(AjaxMethod));
if(!Page.IsPostBack)
{
this.exc_dept.DataSource=AjaxMethod.GetexcdeptList();
this.exc_dept.DataTextField="excdept";
this.exc_dept.DataValueField="excdeptid";
this.exc_dept.DataBind();
this.exc_dept.Attributes.Add("onclick","excclassResult();");
this.exc_class.Attributes.Add("onclick","exczbResult();");
}
3.Ajax代码
public class AjaxMethod
{
// private Connection conFlowER;
public AjaxMethod()
{
//
// TODO: 在此处添加构造函数逻辑
// conFlowER = new Connection(DatabaseType.Kernal);
// // string sql="select item_name,item_value from fm_code_list where form_kind='BQS.FORM.T601' and field_name='F01'";
}
#region GetexcdeptList
public static DataSet GetexcdeptList()
{
string sql="select * from excdept";
return GetDataSet(sql);
}
#endregion
#region GetexcclassList
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
public DataSet GetexcclassList(int excdeptid)
{
string sql="select * from excclass where father="+excdeptid;
// string sql="select item_name,item_value from fm_code_list where form_kind='BQS.FORM.T601' and field_name='F02'";
return GetDataSet(sql);
}
#endregion
#region GetexczbList
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
public DataSet GetexczbList(int excclassid)
{
string sql="select * from exczb where father="+excclassid;
// string sql="select item_name,item_value from fm_code_list where form_kind='BQS.FORM.T601' and field_name='F03'";
return GetDataSet(sql);
}
#endregion
#region GetDataSet
public static DataSet GetDataSet(string sql)
{
string ConnectionString=System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
SqlDataAdapter sda =new SqlDataAdapter(sql,ConnectionString);
DataSet ds=new DataSet();
sda.Fill(ds);
return ds;
}
#endregion
}
4.web.config
<httpHandlers>
<add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax" />
</httpHandlers>
5.ajax.dll下载/Files/singlepine/Ajax.rar
相关文章推荐
- 【Vegas原创】Ajax实现无刷新三联动
- 菜鸟学Java(七)——Ajax+Servlet实现无刷新下拉联动
- ajax实现dropdownlist与datagrid或Repeater无联动刷新
- ajax实现dropdownlist与datagrid或Repeater无联动刷新
- Ajax实现无刷新三联动下拉框
- [原创]超级经典聊天室系统实现 Ajax+PHP+Javascrcript+Json无刷新技术倾力打造(一)
- 用Ajax.net实现的一个无刷新的多级联动下拉列表框
- Ajax无刷新技术实现省市县三级联动下拉菜单--Asp.Net
- 【原创】Asp中使用Ajax实现无刷新调用页面。
- Ajax实现无刷新三联动下拉框
- 【Vegas原创】使用GreyBox组件实现ajax弹出式窗口效果
- AjaxPro实现无刷新多级联动实例
- jQuery+php+mysql,轻松实现ajax无刷新省市二级联动
- AJAX实现DropDownList无刷新二级联动(转载)
- 用DropDownList实现Ajax无刷新省市三级联动中出现的错误
- Ajax实现无刷新三联动下拉框
- 整理:dotNet Ajax实现无刷新省市县三级联动菜单
- Ajax实现无刷新三联动下拉框
- 实现无刷新三级联动菜单[VS2005与AjaxPro]
- ajax+xml实现省市区无刷新联动代码 for Dotnet 附源码示例