Please Help me, How to rearrange set of asp.net panels (or Divs) in C#
Let me explain the scenario:
I have 10 static asp.net Panels. Each panel have many controls(max:8) in it. Based on the setting (from DB), I need to arrange (reordering) those divs and render to the page. Thanks in 开发者_运维百科advance.
I would say you have 3x options
1) Add panels to user controls (as described in Dante's answer). This is simplest if you have many controls but few pages
2) Build the panels dynamically and add the child controls to the panels. This would be simpler if you have few controls and many pages - adding child controls based on a switch statement or similar.
3) Render the page with all panels in the same order and then reorder the divs using client side javascript based on the database order.
You can put your panels in User Controls and load them dynamically in code. The order in which you load them is the order in which they will be displayed.
To load the user control:
Control myUserControl = (Control)Page.LoadControl("MyUserControl.ascx");
somePlaceHolder.Controls.Add(myUserControl);
精彩评论