I have a session variable that I set to zero at every Page_Load beginning:
Session["DoRefresh"] = "0";
On a dropdown value changed, in the event handler I do:
Session["DoRefresh"] = "1";
On the end of aspx page I have a javascript added:
function OnRequestEnd(sender, args) {
if ('<%= Session["DoRefresh"] != null ? Session["DoRefresh"].ToString() + "test" : "0" %>' == '1') { // call some refresh javascript functions }
"test" is added here only for debugging to differentiate it from the zero after ":"
And I am not touching the session variable anywhere else but on the three places. I am using a session var since I plan to extend its usage in PageLoad, but the problem I am blocked with already is that I see from Chrome debugger the "if line" is resulting with
if ('0test' == '1')
It looks the session variable is still 0 in the moment its value is added to the aspx page to render. But how could it be, it is specified embedded code is executed in Render phase, which we know is afterward postback events handling. How could this be?