I'm trying to update global javascript variables from ASP.NET code. What I've tried to do is use an UpdatePanel like that:
<asp:UpdatePanel ID="UpdatePanel" runat="server">
<ContentTemplate>
<script type="text/javascript">
var global1= <%= this.Method(parameter) %>;
var global2= <%= this.Method(parameter) %>;
</script>
</ContentTemplate>
</asp:UpdatePanel>
The UpdatePanel has a trigger (wich is not shown on the code) that fires the update. I have also an endRequest method:
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_initializeRequest(InitializeRequest);
prm.add_endRequest(EndRequest);
function EndRequest(sender, args) {
compute();
}
If I use software like 'Firebug' to inspect the code I can perfecly see how global variables are updated to his new value (when asyncpostback occurs). Unfortunately if I put an alert showing his values inside compute function they have the previous value.
Where's the mistake? Is it possible to update the variables this way from ASP.NET?
Thanks a lot ;)