Click here to Skip to main content
15,886,036 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using
ScriptManager.RegisterArrayDeclaration
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???
Posted

1 solution

According to Microsoft there is no way to replace - only to add...
Quote:
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[^]
 
Share this answer
 
Comments
VICK 2-Jan-14 5:11am    
Thanks for your precious time. but is there any other way to perform what I want??
Kornfeld Eliyahu Peter 2-Jan-14 5:18am    
Can you explain more on what you try to do?
There is any connection between the original array the new send on timer tick?
Did you considered to use aspx page as the source of your js array?
VICK 3-Jan-14 2:13am    
on aspx page a timer is placed for an update panel. and inside that Update Panel there is a repeater which is getting bind with the fresh data on each timer click. and based on that fresh data, I have to remove the div's from the page, for example initially repeater had div 1, div 2 and div 3.. and on timer tick ,, now repeater have only div 1 and div 3, so I want to pass the div1 and div 3 to the array on aspx page.. so that except those div's other could be rmoved...

M I clear enough???
Kornfeld Eliyahu Peter 4-Jan-14 14:57pm    
Isn't your repeater is a server side? So bind it to some data source and refresh that data source on timer...
VICK 6-Jan-14 5:46am    
AHHHHH.. you didnt understand me.. I am refreshing the datasource on timer tick and rebinding the repeater as well , and it is working fine too. I just have to send the data which is in repeater to the client side so perform some client side functionality.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900