Passing data to use with client javascript

  • Thread starter Thread starter Alfredo Magallón Arbizu
  • Start date Start date
A

Alfredo Magallón Arbizu

Hello,

I need to pass the contents of a dataset to the client in order to use these
contents with javascript.

What is the best way to achieve that?

Normally I use controls like a grid or text boxes and then I read the values
using javascript objects.

Any other ideas? Greatly appreciated.

Thanks,
Alfredo
 
Alfredo,

I often find myself using javascript arrays to accomplish this. You can
create the arrays manually or try the Page.RegisterArrayDecleration method.
Multi dimensional arrays really aren't an option in Javascript, but, nested
arrays are. Here's an example from classic ASP of transfering an array ... I
like filling arrays like this because you can access the items like:
arrApprovers[ ApproverID ].FullName ....

var arrApprovers = new Array();
<%if IsArray(arrApprovers) then %>
<% for counter = 0 to UBound(arrApprovers,2) %>
arrApprovers['<%=arrApprovers(0,counter)%>'] = new Array();
arrApprovers['<%=arrApprovers(0,counter)%>']['FullName'] =
'<%=JSClean(arrApprovers(1,counter))%>';
arrApprovers['<%=arrApprovers(0,counter)%>']['Title'] =
'<%=JSClean(arrApprovers(3,counter))%>';
<% next %>
<% end if %>

Alex Papadimoulis
 
Back
Top