Question

I am pretty new to ASP.NET programming. Now I try to add several web user controls to my page dependent on checked boxes in a tree view that I create from data of my database.

I was thinking about using iframes - one for the tree view and the other one for the controls, but this seems quite complicated. Is there an easier way to do this?

The tree view should always remain on the page an the web user controls should appear or disappear in a scrollable part of the page. Could you tell me what would be good practice to resolve this issue?

Was it helpful?

Solution

iframes would not be the easiest way to go about this (as you have two different server side pages that cannot communicate with each other).

If the number of controls that you are controlling visibilty for is not large, I would suggest that you have your user controls in a panel on the page, all invisible, and the treeview and this panel all on the page, within an update panel.

On check of the treeview, in the partial postback, show/hide the appropriate web user control.

As noted above, dynamically adding controls is problematic, as they have to be re-added every postback and you run into state issues.

OTHER TIPS

Dynamic controls added to the page need to be added back to the page on every postback. I would not use iframes for this; instead, you can have the tree view on the left in a floating div, and another floating div for the right content. If the right content is always checkboxes, use a ListView, Repeater, or some other data bound control that builds the control tree for you. It's much easier to work with these controls as long as the UI is consistent. If not, you can build the right side dynamically. You'd have to readd the checkboxes to the page on all future postbacks.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top