Tuesday, 31 August 2010

More ASP.NET AJAX UpdatePanel excitement

I gave up. The UpdatePanel wasn't really designed to do what I want it to do. I thought initially that I could get nested UpdatePanels to just refresh localised content; i.e. if I created one inside a div then by setting it to conditional update I could just make it refresh the controls inside the div. This is not the case - event nested panels refresh everything.

The Conditional update flag is OK but you can't make a control that's outside the panel refresh it. And having a timer that refreshes content is a no - no for the reason discussed above; every ten seconds everything gets refreshed which means the text box you are typing into loses focus and the modal popup with a list of options pops down again.

I have a series of scripts that I have embedded into the main .aspx page via .ascx controls. These scripts open a new app hosted on an entirely seperate server in a new IE tab. Once the user has finished with this second app I need a way to refresh the content on the main .aspx page so what I ended up doing was navigating through the control structure of the main page from the .ascx control and finding the labels etc. that I want to update. I rigged up a modal popup with a giant refresh button and when the user jumps out to the second app this modal popup gets popped and it's the first thing the user sees when they close the second app. The refresh button then brings my main page up to date.

Navigating the control structure was a bit of a nightmare; set Me.Parent.Page and then iterate through five layers of controls to find the one I want (and that's just to pick out one label, there's more work to do). But at least I found a viable solution.

No comments: