Simplest way to update a client-side javascript array variable during a ASP.NET AJAX postback in an

Posted by Noel on Stack Overflow See other posts from Stack Overflow or by Noel
Published on 2008-09-18T17:59:10Z Indexed on 2010/04/26 12:03 UTC
Read the original article Hit count: 313

Filed under:
|
|

If I want to inject a globally scoped array variable into a page's client-side javascript during a full page postback, I can use:

this.Page.ClientScript.RegisterArrayDeclaration("WorkCalendar", "\"" + date.ToShortDateString() + "\"");

to declare and populate a client-side javascript array on the page. Nice and simple.

But I want to do the same from a async postback from an UpdatePanel.

The closest I can figure so far is to create a .js file that just contains the var declaration, update the file during the async postback, and then use a ScriptManagerProxy.Scripts.Add to add the .js file to the page's global scope.

Is there anything simpler? r iz doin it wrong?

© Stack Overflow or respective owner

Related posts about c#

Related posts about JavaScript