using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;namespace SetPosByAttr
{
public partial class _Default : System.Web.UI.Page, ICallbackEventHandler
{
public string m_ADFCallbackFunctionString;
protected void Page_Load(object sender, EventArgs e)
{
m_ADFCallbackFunctionString = Page.ClientScript.GetCallbackEventReference(this, "message",
"processCallbackResult", "context", "postBackError", true);
}
public string GetCallbackResult()
{
return "Callback result";
}
public void RaiseCallbackEvent(string eventArgs)
{
System.Collections.IEnumerable.func_enum = null;
//获取当前map1控件中所有的functionality
func_enum = Map1.GetFunctionalities(); System.Data.DataTable datatable;
//对所有的functionality进行遍历
foreach (ESRI.ArcGIS.ADF.Web.DataSources.IGISFunctionality gisfunctionality in func_enum)
{
ESRI.ArcGIS.ADF.Web.DataSources.IGISDataSource gisresource = null;
//得到该functionality的resource
gisresource = gisfunctionality.Resource;
//判断该resource是否支持IQueryFunctionality
bool support = false;
supported = gisresource.SupportsFunctionality(typeof(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality));
if (supported)
{
ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality qfunc;
qfunc = (ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality)gisresource.CreateFuntionality(typeof(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality), null);
string[] lids;
string[] lnames;
//获得图层的layerId和layerName,GetQueryableLayers的重载方法可以指定图层类型
qfunc.GetQueryableLayers(null, out lids, out lnames); int selindex = -1;
for (int i = 0; i < lids.Length; i++)
{
if (lnames[i] == "变压器")
{
//找到变压器图层的序号
selindex = i;
break;
}
} if (selindex > -1)
{
//设置过滤器的过滤条件
ESRI.ArcGIS.ADF.Web.SpatialFilter spatialfilter = new ESRI.ArcGIS.ADF.Web.SpatialFilter();
spatialfilter.ReturnADFGeometries = true;
spatialfilter.MaxRecords = 100;
spatialfilter.WhereClause = "name like '%" + eventArgs + "%'"; //对指定的图层进行查询,查询的结果保存为
datatable = qfunc.Query(null, lids[selindex], spatialfilter);
if (datatable != null)
{
if (datatable.Rows.Count > 0)
{
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.Point pnt = (ESRI.ArcGIS.ADF.Web.Geometry.Point)datatable.Rows[0][j];
Map1.CenterAt(pnt);
m_ADFCallbackFunctionString = Map1.CallbackResults.ToString();
return;
}
} }
else
{
object[] ob = new object[1];
string sa = "alert('没有找到该变压器');";
ob[0] = sa;
ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult callbackresult = new ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult(null, null, "Javascript", ob);
Map1.CallbackResults.Add(callbackresult);
m_ADFCallbackFunctionString = Map1.CallbackResults.ToString(); }
}
}
} } }
}
}我复制书上的代码,自己运行就出现错误,愁了一天了没解决,求求救啊
错误 3 “ASP.default_aspx.GetTypeHashCode()”: 没有找到适合的方法来重写
错误 4 “ASP.default_aspx.ProcessRequest(System.Web.HttpContext)”: 没有找到适合的方法来重写
错误 5 “ASP.default_aspx”不实现接口成员“System.Web.IHttpHandler.IsReusable”
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;namespace SetPosByAttr
{
public partial class _Default : System.Web.UI.Page, ICallbackEventHandler
{
public string m_ADFCallbackFunctionString;
protected void Page_Load(object sender, EventArgs e)
{
m_ADFCallbackFunctionString = Page.ClientScript.GetCallbackEventReference(this, "message",
"processCallbackResult", "context", "postBackError", true);
}
public string GetCallbackResult()
{
return "Callback result";
}
public void RaiseCallbackEvent(string eventArgs)
{
System.Collections.IEnumerable.func_enum = null;
//获取当前map1控件中所有的functionality
func_enum = Map1.GetFunctionalities(); System.Data.DataTable datatable;
//对所有的functionality进行遍历
foreach (ESRI.ArcGIS.ADF.Web.DataSources.IGISFunctionality gisfunctionality in func_enum)
{
ESRI.ArcGIS.ADF.Web.DataSources.IGISDataSource gisresource = null;
//得到该functionality的resource
gisresource = gisfunctionality.Resource;
//判断该resource是否支持IQueryFunctionality
bool support = false;
supported = gisresource.SupportsFunctionality(typeof(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality));
if (supported)
{
ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality qfunc;
qfunc = (ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality)gisresource.CreateFuntionality(typeof(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality), null);
string[] lids;
string[] lnames;
//获得图层的layerId和layerName,GetQueryableLayers的重载方法可以指定图层类型
qfunc.GetQueryableLayers(null, out lids, out lnames); int selindex = -1;
for (int i = 0; i < lids.Length; i++)
{
if (lnames[i] == "变压器")
{
//找到变压器图层的序号
selindex = i;
break;
}
} if (selindex > -1)
{
//设置过滤器的过滤条件
ESRI.ArcGIS.ADF.Web.SpatialFilter spatialfilter = new ESRI.ArcGIS.ADF.Web.SpatialFilter();
spatialfilter.ReturnADFGeometries = true;
spatialfilter.MaxRecords = 100;
spatialfilter.WhereClause = "name like '%" + eventArgs + "%'"; //对指定的图层进行查询,查询的结果保存为
datatable = qfunc.Query(null, lids[selindex], spatialfilter);
if (datatable != null)
{
if (datatable.Rows.Count > 0)
{
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.Point pnt = (ESRI.ArcGIS.ADF.Web.Geometry.Point)datatable.Rows[0][j];
Map1.CenterAt(pnt);
m_ADFCallbackFunctionString = Map1.CallbackResults.ToString();
return;
}
} }
else
{
object[] ob = new object[1];
string sa = "alert('没有找到该变压器');";
ob[0] = sa;
ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult callbackresult = new ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult(null, null, "Javascript", ob);
Map1.CallbackResults.Add(callbackresult);
m_ADFCallbackFunctionString = Map1.CallbackResults.ToString(); }
}
}
} } }
}
}我复制书上的代码,自己运行就出现错误,愁了一天了没解决,求求救啊
错误 3 “ASP.default_aspx.GetTypeHashCode()”: 没有找到适合的方法来重写
错误 4 “ASP.default_aspx.ProcessRequest(System.Web.HttpContext)”: 没有找到适合的方法来重写
错误 5 “ASP.default_aspx”不实现接口成员“System.Web.IHttpHandler.IsReusable”
然后再试