I’m having problems closing WebContainers using the Scrolling Containers method.
I can create new containers within the scrolling container with no problem. I can also individually close the containers using self.close. However, if I loop through each container in the scrolling container to close them, the container won’t go away…
Here’s the code that I’m running to clear the Containers Controls from the Scrolling Container. As I close the container, I can see the Control Count decrease right, but it’s still visible…
[code] dim theControlCount as integer = PortalScrollingContainer1.ControlCount
dim theControlCountCheck as integer
dim theControl as WebObject
For i As Integer = theControlCount - 1 DownTo 0
theControl = PortalScrollingContainer1.ControlAtIndex( i )
if theControl IsA WebContainer then
WebContainer(theControl).Close
theControlCountCheck = PortalScrollingContainer1.ControlCount
End if
exit
Next[/code]
you might also want to try keeping your own array of references to the controls. Then you can just call Close on everything in the array and then redim the array.
Thanks David! I tried that before I make the video. I was thinking that If I could click the button, then your suggestion would have worked, but they didn’t go away.
That’s how I was doing things yesterday. I had an array of WebContainers on my Scrollable Container. I looped thru them closing and then redim’ed to -1. I thought that I somehow lost a reference as it was behaving the exact same way. So, I reworked it so I could just close the container in the scrollable container.
Just tried David’s idea again. I made a method on the Containers that fill the ScrollingContainer called “CloseSelf” that just calls “self.close”.
The behavior was the same. The WebContainers that closed themselves were no longer included in the ControlCount, but were visible when the page loaded.
I’m stuck. Here’s my code… The exit near the bottom is there so it only closes the first one so I can test how they behave.
For i As Integer = theControlCount - 1 DownTo 0
theControl = PortalScrollingContainer1.ControlAtIndex( i )
if theControl IsA WebContainer then
' WebContainer(theControl).Close
if theControl IsA SettingsProductsCategories then
SettingsProductsCategories(theControl).CloseSelf
End if
theControlCountCheck = PortalScrollingContainer1.ControlCount
End if
exit
Next
Im looking back at my own code of how I managed this and it looks like I hit the same problem. I can verify that it still doesnt remove them from the browser.
In my case they are all container controls and as created stored in an array. Closing them doesnt actually do anything on the browser side. My current implementation has me setting their left value to 100000 or some really large number to move them off the page and then closing them. I dont know why I didnt just make them invisible, perhaps that wasnt working at the time either.
I only close controls when you delete a dynamically created control from the page, so there will never be thousands of them and they will never build up as you use it until the point the browser chokes on them. But the browser will eventually choke on them if youre doing a very dynamic page with lots of them coming and going.
I did a little search though feedback and I dont see this as a bug report yet, please do make a bug report and post the link so we can sign on.
On our Web Page, we we’re using containers to hold stuff as if it was a tab in a tab control. When someone changes the “tab”, we make all the containers invisible and make the active “tab” visible. So when call our Load method, the “tab” that has the scrolling container on it is invisible.
So I just make a quick change to always keep it visible and it works properly.
Based on that, I think that closing a WebContainer that is within a non visible container does close, but it’s not removed from the page.
Hmm…we use the array method and loop through it, set container.visible to false to force the page to refresh, then close them. And then finally redim the array. Never had an issue with it.
That’s working! I just prevented the containers that I use for “tabs” from going invisible. When I set their left to 10000 and keep them visible they close normally!
For anyone following this, Robin was able to create an example file which show the issue quite nicely. It’s attached to the Feedback Case linked above.