如何使用ScriptManager.RegisterArrayDeclaration用新数组替换数组 [英] how to replace array with new array using ScriptManager.RegisterArrayDeclaration

查看:49
本文介绍了如何使用ScriptManager.RegisterArrayDeclaration用新数组替换数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用

ScriptManager.RegisterArrayDeclaration

从服务器端传递一个数组,以便在页面上的外部JS中定义的java脚本函数中使用。

我的问题是这在Timer_Click事件上反复发生。



所以最初当我传递一个数组时,假设在其索引0中包含161,它可以正常工作。比下一次timer_click我在服务器端的索引0中只有162个值。但是当数组传递给JS时,它会附加最后传递的数组,从而使它包含161& 162.



如何避免这种情况?我想用new更新以前使用的数组而不是追加。



ANY help ???

to pass an array from server side to be used in a java script function defined in external JS on the page.
My problem is that this is happening repeatedly on Timer_Click event.

so initially when i pass an array let suppose containing 161 in its index 0 it works fine. than on the next timer_click I have only 162 value in index 0 on server side. but when array is passed to JS, it appends the last passed array, thus making it contains 161 & 162.

How can i avoid this?? I want to update the previously paased array with new and not to append.

ANY help???

推荐答案

根据微软没有办法替换 - 只能添加......

According to Microsoft there is no way to replace - only to add...
引用:

RegisterArrayDeclaration检查是否存在与arrayName参数中指定的名称相同的已注册数组,如果存在,则添加arrayValue参数中指定的值。由于底层存储机制基于ArrayList,因此允许重复。如果不存在与arrayName参数同名的已注册数组,则会创建它并添加arrayValue参数中的值。

The RegisterArrayDeclaration checks to see whether a registered array exists with the same name as the name specified in the arrayName parameter and, if so, adds the values specified in the arrayValue parameter. Because the underlying storage mechanism is based on an ArrayList, duplicates are allowed. If a registered array with the same name as the arrayName parameter does not exist, it is created and the values in the arrayValue parameter added to it.



http://msdn.microsoft.com/en-us/library/system .web.ui.clientscriptmanager.registerarraydeclaration(v = vs.110).aspx [ ^ ]


这篇关于如何使用ScriptManager.RegisterArrayDeclaration用新数组替换数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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