P
Pete Hurst
[Possibly duplicate - something went wrong due to Windows Live ID (I think)
and my first attempt got semi-lost. It appears on the web, but with a date 3
days in the future, and is not showing at all in Windows Mail. I am now
avoiding Windows Live ID...]
I've been setting up AJAX browser history on a major project, and it's
generally working very nicely. I've run into two specific problems however
which are giving me real headaches;
1. Strange double-postback.
If any state strings contain % characters (i.e. URL-encoded values) then a
double-postback is triggered for absolutely no reason. Specifically I'm
storing a path in the browser state, so the forward slashes get encoded, and
the page performs *two* partial updates for no obvious reason. To work
around this I'm substituting the / for an _ and then I get a single postback
as expected. But other values I'm storing in the state might occasionally
have URL-encodable characters and there's no way I can prevent this, or know
what characters might be there, so is this a known problem and is there a
fix or better workaround? (For instance, I am storing the text of a search
query in the browser state. This is user-inputted so could contain
anything!)
2. ScriptManager.IsInAsyncPostback is false when it shouldn't be.
I think this is a page lifecycle issue. In response to a button click by the
user, I am attempting to set a browser history point. This causes an
InvalidOperationException "A history point can only be created during an
asynchronous postback." - even when I have already called the Update method
on one of my UpdatePanels.
I'm loading all my controls very early in the page lifecycle, to ensure that
a number of dynamically created controls work properly. So it seems that
when the button click is fired at this stage, the ScriptManager is not yet
aware that it is performing an AJAX update. Later on in the page lifecycle
I've verified that IsInAsyncPostback becomes true. Is there any further
information on exactly when it's safe to add history points?
Thanks,
Pete Hurst
and my first attempt got semi-lost. It appears on the web, but with a date 3
days in the future, and is not showing at all in Windows Mail. I am now
avoiding Windows Live ID...]
I've been setting up AJAX browser history on a major project, and it's
generally working very nicely. I've run into two specific problems however
which are giving me real headaches;
1. Strange double-postback.
If any state strings contain % characters (i.e. URL-encoded values) then a
double-postback is triggered for absolutely no reason. Specifically I'm
storing a path in the browser state, so the forward slashes get encoded, and
the page performs *two* partial updates for no obvious reason. To work
around this I'm substituting the / for an _ and then I get a single postback
as expected. But other values I'm storing in the state might occasionally
have URL-encodable characters and there's no way I can prevent this, or know
what characters might be there, so is this a known problem and is there a
fix or better workaround? (For instance, I am storing the text of a search
query in the browser state. This is user-inputted so could contain
anything!)
2. ScriptManager.IsInAsyncPostback is false when it shouldn't be.
I think this is a page lifecycle issue. In response to a button click by the
user, I am attempting to set a browser history point. This causes an
InvalidOperationException "A history point can only be created during an
asynchronous postback." - even when I have already called the Update method
on one of my UpdatePanels.
I'm loading all my controls very early in the page lifecycle, to ensure that
a number of dynamically created controls work properly. So it seems that
when the button click is fired at this stage, the ScriptManager is not yet
aware that it is performing an AJAX update. Later on in the page lifecycle
I've verified that IsInAsyncPostback becomes true. Is there any further
information on exactly when it's safe to add history points?
Thanks,
Pete Hurst