| Author: Venkat Tammineni 20 Nov 2008 | Member Level: Gold | Rating:  Points: 6 |
hi,
Once you have your array list populated, you can loop through it and piece together a string. Then simply put this string in a hidden field to make it accessible to javascript.
Detailed example:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim List as New ArrayList()
'Populate Array List
HiddenField1.Value = ArrayListToString(List) End Sub
Private Function ArrayListToString(ByRef _ArrayList as ArrayList) As String Dim intCount as Integer Dim strFinal as String = ""
For intCount = 0 to _ArrayList.Items.Count - 1 If intCount > 0 strFinal += "~" End If
strFinal += _ArrayList.Items(intCount).ToString Next
Return strFinal End Function
Now in javascript, retrieve the data like this:
<script language="javascript" type="text/javascript"> window.onload = function() { var listString = document.getElementById('HiddenField1').value; var listArray = listString.split('~');
// Now you have an array in javascript of each value
for(var i = 0; i < listArray.length; i++) { alert(listArray[i]); }
} </script>
Thanks
|