帮帮忙看看,我用ARCGIS SERVER提供的AJAX老是提醒JS缺少对象
因为初次接触,我学习后,自己编写,有问题,我又照着书编了一次,还是有问题,并且是相同问题,JS缺少对象。。。我缺少不知道错在哪?谢谢,帮忙看看
function searchpostion()
{
var strname=document .getElementById ("provice").value;
if(strname=='')
{
alert('dddddddddddddddddddddddd');
return ;
}
var context="Map1";
var message;
message =strname ;
<%=sADFCallBackFuction%>
}
<script language="javascript" type="text/javascript" src="javascript/searchpostion.js"></script>
<input id="provice" type="text" /><input id="okbut" type="button" value="定位" onclick ="searchpostion();" />
public partial class _Default : System.Web.UI.Page,ICallbackEventHandler
{
public string sADFCallBackFuction;
protected void Page_Load(object sender, EventArgs e)
{ sADFCallBackFuction = Page.ClientScript.GetCallbackEventReference(this, "message", "processCallbackResult", "context","postBackError",true);
}
public void RaiseCallbackEvent(string eventArgument)
{
System.Collections.IEnumerable func_enum = Map1.GetFunctionalities();
System.Data.DataTable datatable;
foreach (IGISFunctionality gisfucn in func_enum)
{
IGISResource gisres = gisfucn.Resource;
bool support = gisres.SupportsFunctionality(typeof(IQueryFunctionality));
if (support)
{
IQueryFunctionality qfunc = gisres.CreateFunctionality(typeof(IQueryFunctionality), null) as IQueryFunctionality;
string[] lids, lname;
qfunc.GetQueryableLayers (null, out lids, out lname);
int setlindes = -1;
for (int i = 0; i < lids.Length; i++)
{
if (lname[i] == "西塞街道办事处(地类)")
{
setlindes = i;
break;
}
}
ESRI.ArcGIS.ADF.Web.SpatialFilter spf = new ESRI.ArcGIS.ADF.Web.SpatialFilter();
spf.ReturnADFGeometries = true;
spf.MaxRecords = 100;
spf.WhereClause = "name='" + eventArgument + "'";
datatable = qfunc.Query(null, lids[setlindes], spf);
if (datatable != null)
{
for (int j = 0; j < datatable.Columns.Count; j++)
{
if (datatable.Columns[j].DataType == typeof(ESRI.ArcGIS.ADF.Web.Geometry.Geometry))
{
ESRI.ArcGIS.ADF.Web.Geometry.Geometry geom = (ESRI.ArcGIS.ADF.Web.Geometry.Geometry)datatable.Rows[0][j];
Map1.Zoom(geom);
sADFCallBackFuction = Map1.CallbackResults.ToString();
return;
}
}
}
}
}
}
public string GetCallbackResult()
{
return sADFCallBackFuction;
}
}
--------------------编程问答-------------------- message =strname;
可能是因为这个strname是在searchpostion()方法里面定义的局部变量,把它放到外面试一下
var strname=document.getElementById ("provice").value;
function searchpostion()
{
--------------------编程问答-------------------- js对象不存在, --------------------编程问答-------------------- 没有成功,我又将那段JS代码放进了HTML中,结果又可以了,不知道为什么。但是新的问题又出现了,不能实现异步刷新,。。。 --------------------编程问答-------------------- 1楼我用了你的方法,但是还是一样的问题。。。 --------------------编程问答-------------------- var strname=document .getElementById ("provice").value;
这行输出一下。。看有值没? --------------------编程问答-------------------- 有值.我已经测试过了
补充:.NET技术 , ASP.NET