473,663 Members | 2,726 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with aligning controls vertically.

I have a user control (with three controls inside it) that appears multiple
times in the containing page. Sometimes I want to hide the rightmost
control in the UC but if I do that it screws up the horizontal alignment of
the other two controls. It appears that they are being stretched due to the
absence of the others and I'm not sure how to fix it.

If I dont hide anything it looks all lined up (each line is a web user
control):
Label DropDownList CheckBox
Label DropDownList CheckBox
Label DropDownList CheckBox

However, sometimes I want to hide the check box for a given line but it
messes up the alignment when I do that (notice the spacing on the second
line):
Label DropDownList CheckBox
Label DropDownList
Label DropDownList CheckBox

What I want is for the vertical alignment of each Label, and each DropDown
to be ok regardless of if the CheckBox shows (and I wan the check boxes
lined up too).
--------------------------------------------
Here is the HTML I use for the User Control:
<table width=375 border=0 cellpadding=0 cellspacing=0>
<tr width=100%>
<td width=35%>
<asp:Label ID="labelName" runat="server" Text="Label" Font-Bold="True"
</asp:Label>

</td>
<td width=50%>
<asp:DropDownLi st ID="ddlData" runat="server" />
</td>
<td width=15%>
<asp:CheckBox ID="chkSuppress " runat="server" Text="Suppress" />
</td>
</tr>
</table>

I tried making the first two columns its own table inside the first column
of the outer table but got the same effect. What I suspect is that since
the third column is hidden for a given row then the first two get stretched
some. If I set the table to show borders it definitely shows the first
two columns oversized.
Can anyone provide advice?

Thanks.
Mar 29 '06 #1
1 3038
Eric wrote:
--------------------------------------------
Here is the HTML I use for the User Control:
<table width=375 border=0 cellpadding=0 cellspacing=0>
<tr width=100%>
<td width=35%>
<asp:Label ID="labelName" runat="server" Text="Label" Font-Bold="True"
></asp:Label>

</td>
<td width=50%>
<asp:DropDownLi st ID="ddlData" runat="server" />
</td>
<td width=15%>
<asp:CheckBox ID="chkSuppress " runat="server" Text="Suppress" />
</td>
</tr>
</table>

I tried making the first two columns its own table inside the first column
of the outer table but got the same effect. What I suspect is that since
the third column is hidden for a given row then the first two get stretched
some. If I set the table to show borders it definitely shows the first
two columns oversized.
Can anyone provide advice?

Thanks.


I assume since you showed 1 table, that for your example output you have
<table> after <table> after <table> (3 tables). Why not have the
'repeating' effect happen by adding rows to the table (3 rows in 1
table), then the controls are in cells and can't move:

<table width=375 border=0 cellpadding=0 cellspacing=0>
<tr width=100%>
<td width=35%>
label
</td>
<td width=50%>
dropdownlist
</td>
<td width=15%>
checkbox
</td>
</tr>
<tr width=100%>
<td width=35%>
label
</td>
<td width=50%>
dropdownlist
</td>
<td width=15%>
checkbox
</td>
</tr>
<tr width=100%>
<td width=35%>
label
</td>
<td width=50%>
dropdownlist
</td>
<td width=15%>
checkbox
</td>
</tr>
</table>

--
Craig
Microsoft MVP - ASP/ASP.NET
Mar 29 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3166
by: Iain Hallam | last post by:
Hi. I've got a few divs on a page that are positioned as "fixed". I now want my text to centre itself both horizontally and vertically. "text-align: center" on the body works for horizontal, but I can't seem to get the text to move from the top of each div. Any suggestions? Incidentally, the page layout I'm aiming for is as follows: ..-------------------------------------------.
0
828
by: AlexB | last post by:
Hey all, I've got an ASP.NET app with a user control. The problem I have is that the controls in the user-control align vertically differently, i.e. the textboxes and dropdownlists align with the bottom and the imagebuttons align with the top. Needless to say this makes the user- control look bad! Anyone know how to fix this?
7
1655
by: Scott Teglasi | last post by:
Hi all, I was curious as to how others whom have dealt with this problem have handled it. The problem is that I have a site design of a fixed width and height and want to center that content in the middle of the browser's viewport, both horizontally AND vertically. The site I'm building requires that I adhere to the HTML 4.01
2
2751
by: Dave | last post by:
Hello all, I need to know if you can vertically align Items within an ItemTemplate. For example I have two columns, one column has a stack of 6 textboxes, my second column can have 1 to n number of textboxes, but when there is only one textbox I need to be able to anchor it to the top of the column, at present it centers itself in the middle. Does anyone have any idea how to accomplish this?
3
1971
by: Mark Wiewel | last post by:
hi all, i am a newbie in ASP.NET and i couldn't find the solution to this one: i have a form with three datagrids on it. i would like to align them vertically with a space between each grid of about 20px. the amount of rows in those grids is changing, but the position of each datagrid seems to be fixed. this results in a grid overlaying another one or the space between two grids is way too high.
4
15902
by: Greg Scharlemann | last post by:
I'm having difficulty getting the radio buttons to align vertically with one another and the header (1 2 3 4 5) at the top. Ideally each radio button will be directly below the one above it and the number 1 will be atop the first radio button starting at the left. Any thoughts on how to achieve this? <html> <head> <title></title> <style type="text/css">
2
4138
by: Casimir | last post by:
What would be the correct way to align checkboxes and their labels, in your opinion? For example .... <td> <input type="checkbox" class="cbox" name="thisCheck" /> <label for="thisCheck">Check this if you want a copy</label><br/> </td>
7
6034
by: Bram2 | last post by:
Sorry if this sounds like a dumbass newbie question. I'm getting crazy or something, but somehow I can't get this simple thing to work: 1. In general, how do I center text and/or images vertically? 2. How would I do a top bar with a logo on the left, and an icon + text + combobox (small form with one select item) on the right, all vertically centered to eachother? Like this: http://i41.tinypic.com/2mhv1gl.gif And with "how", I mean:...
1
1431
by: brixton | last post by:
Hello. I have the following setup: <div> <img /> <a>Something</a> </div>
0
8436
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8548
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7371
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5657
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4182
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4349
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2000
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1757
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.