I have a timer update panel configured to automatically check for data updates every minute or so.
If he sees that data updates, he is configured to invoke a local script with serialized JSON data.
ScriptManager.RegisterStartupScript(UpdateField, GetType(HiddenField), ACTION_CheckHistoryVersion, "updateData(" & data & ");", True)
where "data" might look something like
{ "someProperty":"foo", "someOtherProperty":"bar", "someList":[ {"prop1":"value"}, {"prop2":"value"}, ... ], "someOtherList":[{},...,{}] }
"data" can be quite large, and sometimes only a few elements change.
I'm having a problem. Each time I send this back to the client, it is added as a new script block, and existing blocks are not deleted or replaced.
the output looks something like this:
<script type="text/javascript"> updateData({ "someProperty":"foo", "someOtherProperty":"bar", "someList":[ {"prop1":"value"}, {"prop2":"value"}, ... ], "someOtherList":[{},...,{}] }); </script> <script type="text/javascript"> updateData({ "someProperty":"foo", "someOtherProperty":"bar", "someList":[ {"prop1":"changed"}, {"prop2":"val"}, ... ], "someOtherList":[{},...,{}] }); </script> <script type="text/javascript"> updateData({ "someProperty":"foos", "someOtherProperty":"ball", "someList":[ {"prop1":"changed"}, {"prop2":"val"}, ... ] }); </script>
with a new script block created each time a data change occurs.
Over time, the amount of data accumulating in the browser can become potentially huge if we just add it, and I canโt imagine how most browser users will do it, but I donโt think it could be good.
Does anyone know if there is a way to simply replace the code that was sent back to the browser and not constantly add it like that?