I my.aspx.vb page, I dynamically declare and add panels as such:
Dim Panels(5) As Panel
For i As Integer = 0 to 4
Panels(i) = New Panel
...
MainPanel.Controls.Add(Panels(i))
Next
In the ... section I add a few things to my panels, and they all show up perfect well. However, they all show up below each other. Is there anyway I can make the panels show up next to each other? I would like to be able to control which panels appear on
the same line and which ones appear below each other. Is this possible?
Panels render in html as Div tags. You will get div's one below the other because div's are bydefault 'block' style.where as span is 'inline'. In order to get the panels in line add a style attribute to the panel as
I dont know how to change the float. I tried changing the display to inline,but it creates another problem. Inside each panel I have check boxes which have a few lines of text that go with it. When I change the style to inline for each panel, each line in
the panel looks like it has its own panel with a border. I don't want this, and want to be able to have each panel as just one box. When I tried to change only the MainPanel style to inline, the panels' check boxes all appear in one panel/box, but the panels
themselves are left align and still on separate line. Does anyone know what going on?
getting divs to line up next to each other is not always as easy at we might hope. for this reason some developers will still use a table with a single row and many cells to perform this kind of layout.
i use very few tables these days, but i have not abandoned them all together...
Mike Banavige
Marked as answer by Ivan Xin - MSFT on Apr 16, 2008 02:33 AM
Kevat
Member
37 Points
41 Posts
Putting panels next to each other dynamically
Apr 12, 2008 11:05 PM|LINK
I my.aspx.vb page, I dynamically declare and add panels as such:
Dim Panels(5) As Panel
For i As Integer = 0 to 4
Panels(i) = New Panel
...
MainPanel.Controls.Add(Panels(i))
Next
In the ... section I add a few things to my panels, and they all show up perfect well. However, they all show up below each other. Is there anyway I can make the panels show up next to each other? I would like to be able to control which panels appear on the same line and which ones appear below each other. Is this possible?
-Kevat Shah
mbanavige
All-Star
134966 Points
15422 Posts
ASPInsiders
Moderator
MVP
Re: Putting panels next to each other dynamically
Apr 12, 2008 11:10 PM|LINK
panels render as Div tags so the techniques to allow divs to appear next to each will work on panels.
for example, you could add a css style to them of - float:left
bhaskar2583
Member
33 Points
23 Posts
Re: Putting panels next to each other dynamically
Apr 13, 2008 03:38 AM|LINK
Hi,
Panels render in html as Div tags. You will get div's one below the other because div's are bydefault 'block' style.where as span is 'inline'. In order to get the panels in line add a style attribute to the panel as
panel.Attributes.CssStyle.Add("display", "inline");
Thanks
Vijay
Kevat
Member
37 Points
41 Posts
Re: Putting panels next to each other dynamically
Apr 13, 2008 04:36 AM|LINK
I dont know how to change the float. I tried changing the display to inline,but it creates another problem. Inside each panel I have check boxes which have a few lines of text that go with it. When I change the style to inline for each panel, each line in the panel looks like it has its own panel with a border. I don't want this, and want to be able to have each panel as just one box. When I tried to change only the MainPanel style to inline, the panels' check boxes all appear in one panel/box, but the panels themselves are left align and still on separate line. Does anyone know what going on?
mbanavige
All-Star
134966 Points
15422 Posts
ASPInsiders
Moderator
MVP
Re: Putting panels next to each other dynamically
Apr 13, 2008 03:53 PM|LINK
getting divs to line up next to each other is not always as easy at we might hope. for this reason some developers will still use a table with a single row and many cells to perform this kind of layout.
i use very few tables these days, but i have not abandoned them all together...
HomerJ
Member
172 Points
44 Posts
Re: Putting panels next to each other dynamically
Apr 13, 2008 09:08 PM|LINK
use an asp:table which you can programatically change. add your content into its cells (instead of the panels).
e.g.: tabel1.rows[0]....
Kevat
Member
37 Points
41 Posts
Re: Putting panels next to each other dynamically
Apr 13, 2008 10:40 PM|LINK
Thank you both, I will try that.asater
Member
70 Points
61 Posts
Re: Putting panels next to each other dynamically
May 29, 2009 04:16 PM|LINK
Try this:
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <style type="text/css"> div.Outer { width: 350px; border:dashed 1px black; position: relative; clear: both; } div.InnerLeft { width: 50%; position: relative; background: #CCCCCC; float: left; } div.InnerRight { width: 49%; position: relative; background: #AAAAFF; float: right; } </style> </head> <body> <form id="form1" runat="server"> <div class="Outer"> <div class="InnerLeft"> information goes here... </div> <div class="InnerRight"> information goes here... </div> </div> </form> </body> </html>