一个Ajax无刷的代码,供大家学习和交流,这个是在vs2003下使用AJAX的代码,如果大家有好的想法请多提意见,谢谢!!
有兴趣的可以看看这个页面http://shouhou.xx10000.com/result/find.aspx
省份:
[Ajax.AjaxMethod]
public string bind_ddl1()
{
string str = "";
}
// 城市:二级下拉
[Ajax.AjaxMethod]
public string bind_ddl2(string id)
{
string sql;
if(id=="0")
{
sql="select cityID,city from city";
}
else
{
sql="select cityID,city from city where father='"+id+"'";
}
DataTable dt = sts.getDataTable(sql);
string str = "";
}
// 地区:三级下拉
[Ajax.AjaxMethod]
public string bind_ddl3(string id)
{
string sql;
if(id=="0")
{
sql="select areaID,area from area";
}
else
{
sql="select areaID,area from area where father='"+id+"'";
}
DataTable dt = sts.getDataTable(sql);
string str = "";
}
//绑定省份列表事件
function bindPRO_all()
{
$("projs").innerHTML = inforesult.bind_ddl1().value;
}
//城市列表事件
function chanSel_province(obj)
{
projsid = obj.options[obj.selectedIndex].value
$("cityjs").innerHTML = inforesult.bind_ddl2(projsid).value;
}
//地区列表事件
function chanSel_city(obj)
{
cityjsid = obj.options[obj.selectedIndex].value
$("areajs").innerHTML = inforesult.bind_ddl3(cityjsid).value;
}
public DataTable getDataTable(String sql)
{
//把SQL执行的结果封装在一个DataTable中,并返回该DataTable
DataObject ado=new DataObject();
DataTable dt;
try
{
dt=new DataTable();
ado.open();
dt= ado.DTTransSqlQuery(sql);
}
catch(Exception e)
{
new SimpleTools().processException("01",e.Message);
throw(new Exception(e.Message));
}
finally
{
ado.close();
}
return dt;
}