RegisterClientScriptBlock的问题 [英] Issue with RegisterClientScriptBlock

查看:86
本文介绍了RegisterClientScriptBlock的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我对RegisterClientScriptBlock有问题.
场景是,我在javascript中声明了数组,并在后面的代码中将值传递给它.有一个带有checkbox的gridview,其checkstate更改了,我在获取数据,然后再次将其分配给javascript中的数组.

 DataTable tblDeliveries = ;
        tblDeliveries =  ._ bingmapData.SelectDriversDelivery(driverId);

        StringBuilder脚本=  StringBuilder();

         int  i =  0 ;
         foreach (数据行 in 中的tblDeliveries.Rows)
        {
            script.AppendFormat(" ,即第[ 拉特"],行[" ],行[" ]);
            i ++;
        }
ScriptManager.RegisterClientScriptBlock( this  this  .GetType(), " ,script.ToString(), true ); 


这是复选框checkstate change event中的代码.工作正常,但是当我应用updatepanel时,我没有得到想要的结果.在页面Source上,它们是较旧的条目,而不是我从事件传递的新条目.

我花了4个小时在此,最后发现一个很小的东西导致了这个问题.我必须重新初始化数组.
script.AppendFormat("_ locations = new Array();");
真的很小的事情很重要.


Hi,
I have a issue with RegisterClientScriptBlock.
Scenario is,I have array declare in javascript and from code behind I am passing values to it.There is a gridview with checkbox with their checkstate changed I am fetching data and then again assign it to array in javascript.

DataTable tblDeliveries = null;
        tblDeliveries = this._bingmapData.SelectDriversDelivery(driverId);

        StringBuilder script = new StringBuilder();

        int i = 0;
        foreach (DataRow row in tblDeliveries.Rows)
        {
            script.AppendFormat("_locations[{0}]= new VELatLong({1}, {2});_driverColor[{0}]='{3}';", i, row["Lat"], row["Long"], row["DriverColor"]);            
            i++;
        }
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "PointArrays", script.ToString(), true);


This is the code in checkbox checkstate change event.Working fine but when I apply updatepanel i am not getting desired result.On page Source their are older entries not the new that I passed from event.

解决方案

I have spend 4 hours in this and at the end I find a very small thing that causing the problem.I have to reinitialize the array.
script.AppendFormat("_locations=new Array();");
Really small things matters.


这篇关于RegisterClientScriptBlock的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆