0

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?

2
Contributors
1
Reply
14
Views
4 Years
Discussion Span
Last Post by LastMitch
0

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

Edited by LastMitch: grammer

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.