Server Controls And Persistence

posted on 2005-09-25 at 15:57:09 by Joel Ross

As some of you may know, I'm one of the owners of Tourney Logic. We're working on the next version of the bracket control, and I'm having an issue that I'm trying to work through right now. The Tourney Bracket Control (TBC) is a server control that's a little different than most I've seen - especially with some of the changes we've made recently.

Here's why (I think) it's unique. In our control, you add a collection of one type of custom control (teams), and based on how many teams are in that collection, the bracket?creates a whole set of other controls (rounds, matchups, etc.)?and adds them to it's controls collection. Then, when rendering, it's up to each control to determine how it should render itself. From a programming stance, this makes the rendering fairly simple.

But here's where the issues come in. Because the CreateChildControls() method changes the control hierarchy, it's actually changing the markup in the aspx page, which is not what we want to happen. So, when you look at the markup, rather than seeing the teams you added, you see a whole hierarchy of rounds and matchups, which is not what we want.

I think I understand a little bit of what is going on: It's persisting the TBC's control collection, which is now different than what the designer specified it to be. Is there a way to control what gets persisted to the aspx page and what doesn't, separate from the way it's rendered? If you have any ideas, please let me know! I'm banging my head on a wall right now!

Categories: Develomatic