I have an event handler in C# code-behind for an .aspx page. Each time this event handler fires I want it to update a Javascript variable. I thought I could do something like this.
int scale = (int)myObject.Scale;
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "JSVariables", "scale=" + scale, true);
However, as it was pointed out to me earlier here, RegisterClientScript checks first to see whether or not the script has been registered and if it has it does nothing. In essence the variable is updated once then never again.
Is it possible to have this value continuously updated?
The most I can really do with Ajax is to have a static web method. For a couple of reasons that are unnecessary to explain here I can't use a WCF or web service, and the problem with the static web method is the static bit.
Is there any other way?
I was thinking maybe some session trickery but I'm not sure yet.