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?

Member Avatar for LastMitch

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

You mean 'test' in here not '0test'

from this:

if ('0test' == '1')

to this:

if ('test' == '1')

Read this regarding about using Session with Postback:

http://stackoverflow.com/questions/6948533/why-dont-events-of-dynamically-added-user-control-fire-on-postback

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.