急!!!asp.net后台调用js问题

lxbgg lxbgg 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

从数据库里取出数据绑定到gridview后,ButtonField取得ID号,然后再查询数据库,把坐标数据取出来,传到前台js方法,但是不知道怎么触发js事件,ButtonField没有click属性,从后台直接调用js方法也不行,有没有高手指点一下,感激不尽啊!!

前台js方法,

function maker(){
map.clearOverlays();
var x = "<%=longitude%>";
var y = "<%=latitude %>";
alert(x);
alert(y);
   var marker = new BMap.Marker(new BMap.Point(x,y)); // 创建标注
   map.addOverlay(marker); // 将标注添加到地图中
var infoWindow = new BMap.InfoWindow("欢迎光临"); // 创建信息窗口对象
marker.addEventListener("click", function(){ this.openInfoWindow(infoWindow);});

}


后台方法

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "biaozhu")
{
sqlid = e.CommandArgument.ToString();//获取id
}
try
{

string sql = "select longitude,latitude from SYS_LL where id=" + sqlid;
DataSet ds = sqlHelper.getDataSet(sql);
int count = 0;
foreach (DataRow dr in ds.Tables[0].Rows)
{
Longitudes[count] = System.Double.Parse(dr["Longitude"].ToString());
longitude += Longitudes[count] ;//将读取的经纬度存储为字符串形式

Latitudes[count] = System.Double.Parse(dr["Latitude"].ToString());
latitude += Latitudes[count];//将读取经纬度存储为字符串形式
count = count + 1;
}
}
catch (Exception ee)
{
Response.Write(ee.Message);
}
ClientScript.RegisterStartupScript(GetType(), "onclick", "<script>maker();</script>");
}
...全文

相关推荐

评论 2
收藏 已收藏
分享
返回顶部
lxbgg
.NET社区 62,272 成员 668,968 内容