How to transfer a collection to a modal dialog box?

I want to know if it is possible to pass a collection between pages. I want to say that I have a client-side JavaScript modal dialog in which I want to use my collection. I used to use Session [] to share a value, but it becomes evil for me, as it always displays the first value. Any change in value is not updated.

So, whenever a popup appears, I want the collection to be moved to the Child dialog. From there I will extract the collection, do some things, and return it to the parent page again, preventing postbacks and session management.

I think I understand guys. If not clear, add a comment.

+5
source share
1 answer

You can try JSON or just convert your list to a comma-delimited string, which would be very easy to parse using the string split function with JavaScript .

RegisterArrayDeclaration (arrayName, arrayValue) is another option. Check out the link.

From the link:

If you need to create a client part of a JavaScript Array object with some value set, use this method to add a value to a specific array.

To add values ​​1, 2, and 3 to an client-side Array object named FavoriteNumbers, you must use the following server-side code:

RegisterArrayDeclaration("FavoriteNumbers", "1")
RegisterArrayDeclaration("FavoriteNumbers", "2")
RegisterArrayDeclaration("FavoriteNumbers", "3")

This code will emit the following client side script:

<script language="javascript">
<!--
   var FavoriteNumbers =  new Array(1, 2, 3);
      // -->
</script>
+2
source

All Articles