Showing posts with label pages. Show all posts
Showing posts with label pages. Show all posts

Wednesday, March 28, 2012

Very weird error. Ajax controls call default.aspx

I have a few pages in my site... and for some reason, if there's any ajax controls on the page, it calls default.aspx and runs the code every time any aspx page with an ajax control exists on it. Problem is, default.aspx resets my session variables.

Why does Ajax call the default.aspx page code? It only runs the CS file... it doesn't actually show the default.aspx page.

I doubt it calls it. Do you have a component in your site somewhere that's got a url of "/" attached to it somewhere, and that's invoking the default page?


it only seemed to only happen when I have Certain Ajax controls on the page. Note, it only does it with Internet Explorer 6 and 7. Firefox seems to be fine.

For example, I have a collapsible PAnel in each row of a Gridview. That is in an UpdatePanel. When the Gridview is populated (and I have a breakpoint on the default.aspx.cs file), it goes through that code. Well, I set my session variables on that page, so in essence it resets them.

It seems like it does this AFTER the page is loaded, because the labels that show content based on those session variables aren't updated until I go to a new page.

It only does this when I have a collapsible panel in IE. The panel is set to collapsed.


Actually, it appears that AJAX is clearing the Session Variables. I don't know where it's doing this, though.

Viewstate was invalid when using the back button

Ok, this is going to be difficult to explain but I'll do my best. So we have several pages that make significant use of update panels. So you can interact with the page and the update panel does its thing. Then you can click a link that takes you to a different page.

Now, what can possibly happen is this scenario where the user then hits the back button so they are back on the page with the update panel. But they go back to the page and the update panel has reverted to its original state. It doesn't look like what it looked like when they left the page.

If you then click on the page to cause the update panel to do its thing again, you get a "Viewstate verification failed. Reason: Viewstate was invalid." error.

Anyone have any thoughts on this?

Are there any events fired when the back button is pressed? Is there anyway when the back button is pressed that I can set the update panel to be the state that it was in when the user left?

Thanks a lot!

Hi,

ASP.NET Futures inlude special control to control browser history and restore AJAX pages when user clickcs BACK. I have never used it, but as far as I know it is what you are looking for. See:http://quickstarts.asp.net/Futures/ajax/doc/history.aspx

-yuriy
http://weblogs.asp.net/ysolodkyy


The history control works great while you remain on the same page. So you can bounce around within the update panel and then hit back to alter the state within the current page. However, if you navigate away from that page and then hit the back button to go back to your page with the update panel, that's where I'm running into my problem.