tags:

views:

36

answers:

2

Hello everybody.

I'm working with an aspx page, where once I click on a button, some calls are executed in the background and I display the returned information on the webpage. I do this by adding this information to a panel:

panel.controls.add(label)
panel.controls.add(anotherpanel)

Problem is that once I click the button again, and I get some new objects from the background calls the UI elements (those labels and panels) still remain visible and my new information is just added after the previous one.

I would like to have all the previous information gone once I press the new button.

I've tried panel.controls.clear(), but it doesn't do anything.

Any ideas? Thanks.

A: 

You might want to declare label and anotherpanel in the actual markup, and set their visibility to false. Then, just set the visibility to true and replace their values in your codebehind as you acquire results.

Chris
Thanks for the answer Chris, but that doesn't help, since I don't know how many objects I get back from that background call. Could be 10 strings, but it could as well be 100. That's why I have to create the panels and labels in code.
Andrei
+2  A: 

Have you tried setting a breakpoint and check to see that it is not the background calls returning the previous information along with the new ones?

I asked because items that were added programmatically, by itself, shouldn't persist across postbacks.

Amry
Have a correct answer! I thought I actually looked over that quite thoroughly, but now I checked it again, and yeah, since I was using a singleton WCF service, I was not re-initializing a value every time I was making the call. Thanks.
Andrei