在网络上下载了ajax实现dropdownlist无刷新代码,自己做了修改,出现了这样一个问题:当使用Visual Studio调试时(如http://localhost:50242/Ajax-DropDownList/Default.aspx)一切正常(点击第一个下拉框后两个下拉框能实现无刷新修改),当使用IIS发布时(发布后网址为http://127.0.0.1/Ajax-DropDownList/Default.aspx)点击第一个下拉框却提示'AjaxMethod' 未定义,怎么也想不明白为什么,请高手赐教
附上数据库和源代码。
http://d.namipan.com/d/ccce4093b66a9e6ea3435b8fccc5e98008b88cf689140400
我的环境是Windows 7,Visual Studio 2008,使用IIS发布的时候是在Default Web Site上右键添加的应用程序。
附上数据库和源代码。
http://d.namipan.com/d/ccce4093b66a9e6ea3435b8fccc5e98008b88cf689140400
我的环境是Windows 7,Visual Studio 2008,使用IIS发布的时候是在Default Web Site上右键添加的应用程序。
解决方案 »
- 帮我分析一下两种写法有什么不同
- 提示:com.ExecuteNonQuery();语句有误(关键字 'into' 附近有语法错误。)
- 求助 C#对C++ builder所写的DLL的结构体的调用?
- 求vs的小工具或者小技巧
- 绑定GridView
- C# 命名空间??
- 顶者有分~~!!!导出数据到Excel总是出错。数据量超过三万条,一次性导出到Excel.使用C#语言写
- C#如何判断当前输入法是中文输入还是英文输入,注意:是判断,而不是去切换中英文输入
- FileSystemWatcher监视的目录删除时 还会继续监视吗
- 怎样得到datagrid当前选中的行?
- C#Winform DevExpress GridControl 刷新问题
- Clickonce更新安装时,有没有办法可以让用户自定义安装路径啊?
注意事项:1.
pageload()方法中
AjaxPro.Utility.RegisterTypeForAjax(typeof(WebApplication2.AjaxMethod));
2.
AjaxMethod类中
[AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]3.
web.config中
<httpHandlers>
<add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro"/>
</httpHandlers>
4.global.asax的Application_Start方法中AjaxPro.Utility.HandlerPath = "ajaxpro";
1.在pageload中引用了Ajax.Utility.RegisterTypeForAjax(typeof(AjaxMethod));
2.在AjaxMethod.cs 中添加了[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
3.web.config中添加了 <add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax"/>
4.我的程序中没有global.asax
<!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>
<title>web3.cn——Ajax实现无刷新三联动下拉框</title>
<style type="text/css">...
body {...}{COLOR: #333;
FONT-SIZE: 9pt;
LINE-HEIGHT:150%;
FONT-FAMILY: 'Lucida Grande',arial,verdana,sans-serif; }
</style>
<script language="javascript">...
//城市------------------------------
function cityResult()
...{
var city=document.getElementById("DropDownList1");
AjaxMethod.GetCityList(city.value,get_city_Result_CallBack);
}
function get_city_Result_CallBack(response)
...{
if (response.value != null)
...{
//debugger;
document.all("DropDownList2").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].city;
var id=ds.Tables[0].Rows[i].cityID;
document.all("DropDownList2").options.add(new Option(name,id));
}
}
}
return
}
//市区----------------------------------------
function areaResult()
...{
var area=document.getElementById("DropDownList2");
AjaxMethod.GetAreaList(area.value,get_area_Result_CallBack);
}
function get_area_Result_CallBack(response)
...{
if (response.value != null)
...{
document.all("DropDownList3").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].area;
var id=ds.Tables[0].Rows[i].areaID;
document.all("DropDownList3").options.add(new Option(name,id));
}
}
}
return
}
function getData()
...{
var province=document.getElementById("DropDownList1");
var pindex = province.selectedIndex;
var pValue = province.options[pindex].value;
var pText = province.options[pindex].text;
var city=document.getElementById("DropDownList2");
var cindex = city.selectedIndex;
var cValue = city.options[cindex].value;
var cText = city.options[cindex].text;
var area=document.getElementById("DropDownList3");
var aindex = area.selectedIndex;
var aValue = area.options[aindex].value;
var aText = area.options[aindex].text;
var txt=document.getElementById("TextBox1"); document.getElementById("<%=TextBox1.ClientID%>")
.innerText="省:"+pValue+"|"+pText+"市:"+cValue+"|"+cText+"区:"+aValue+"|"+aText;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<table cellspacing="0" border="1" style="width:300px;border-collapse:collapse;background:#ececec;">
<tr>
<td>省市</td>
<td><asp:dropdownlist id="DropDownList1" runat="server"></asp:dropdownlist></td>
</tr>
<tr>
<td>城市</td>
<td><asp:dropdownlist id="DropDownList2" runat="server"></asp:dropdownlist></td>
</tr>
<tr>
<td>市区</td>
<td><asp:dropdownlist id="DropDownList3" runat="server"></asp:dropdownlist></td>
</tr>
</table>
<br />
<asp:TextBox id="TextBox1" runat="server" Width="424px"></asp:TextBox>
<input type="button" value="获取资料" onclick="getData();" />
</form>
</body>
</html>
AjaxMethod命名空间是否正确
三级联动
还是不行,执行到aspx页面的AjaxMethod.GetCityList(city.value, get_city_Result_CallBack);
就报'AjaxMethod' 未定义function cityResult()
{
var city=document.getElementById("DropDownList1");
AjaxMethod.GetCityList(city.value, get_city_Result_CallBack);
}
<add name="POST,GET" verb="*" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax"/>就OK了,是<handlers>,不是<httpHandlers>