473,473 Members | 1,951 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

HTML White Space from Hidden Controls

When an ASP.NET 2.0 web page is rendered with multiple web controls hidden
from view (.visible=false) there is a noticeable gap between a rendered
element (like a table) and the next visible element (e.g. a button). When I
look at the HTML source code there is nothing there except white space (see
below).

First of all, I thought browsers ignore white space and condense it down to
one space, but most of all, how can controls be hidden from the rendered
view so that the controls don't leave gaps between elements (like the
controls are there but they are not)?

Thanks for any tips.

</tr></table>


<input type="submit" name="btnStartOver" value="Start Over"
id="btnStartOver" />
Apr 17 '07 #1
4 2830
tables are a block element with a margin and a border, no whitespace.
set these to 0px and the table will not add any space.

-- bruce (sqlwork.com)

Don Miller wrote:
When an ASP.NET 2.0 web page is rendered with multiple web controls hidden
from view (.visible=false) there is a noticeable gap between a rendered
element (like a table) and the next visible element (e.g. a button). When I
look at the HTML source code there is nothing there except white space (see
below).

First of all, I thought browsers ignore white space and condense it down to
one space, but most of all, how can controls be hidden from the rendered
view so that the controls don't leave gaps between elements (like the
controls are there but they are not)?

Thanks for any tips.

</tr></table>


<input type="submit" name="btnStartOver" value="Start Over"
id="btnStartOver" />

Apr 17 '07 #2
Hi,

Don Miller wrote:
When an ASP.NET 2.0 web page is rendered with multiple web controls hidden
from view (.visible=false) there is a noticeable gap between a rendered
element (like a table) and the next visible element (e.g. a button). When I
look at the HTML source code there is nothing there except white space (see
below).

First of all, I thought browsers ignore white space and condense it down to
one space, but most of all, how can controls be hidden from the rendered
view so that the controls don't leave gaps between elements (like the
controls are there but they are not)?

Thanks for any tips.

</tr></table>


<input type="submit" name="btnStartOver" value="Start Over"
id="btnStartOver" />
Many browsers render new lines in the HTML codes as whitespaces in the
rendered view. The reason is that in a block of text, when you have a
new line in the text, the browser wants to separate the words.
Unfortunately, it also often creates unwanted white spaces when you want
your HTML code to be nicely formatted.

To avoid this, the only certain way is to write
</tr></table><input type="submit"
name="btnStartOver"
value="Start Over"
id="btnStartOver" />

HTH,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Apr 19 '07 #3
Thanks, I didn't know (or expect) that. I guess that also means that I can't
include new lines in my ASP.NET code (for coding formatting) but should make
sure all tags are end-to-end.

"Laurent Bugnion, MVP" <ga*********@bluewin.chwrote in message
news:u2**************@TK2MSFTNGP02.phx.gbl...
Hi,

Don Miller wrote:
>When an ASP.NET 2.0 web page is rendered with multiple web controls
hidden from view (.visible=false) there is a noticeable gap between a
rendered element (like a table) and the next visible element (e.g. a
button). When I look at the HTML source code there is nothing there
except white space (see below).

First of all, I thought browsers ignore white space and condense it down
to one space, but most of all, how can controls be hidden from the
rendered view so that the controls don't leave gaps between elements
(like the controls are there but they are not)?

Thanks for any tips.

</tr></table>


<input type="submit" name="btnStartOver" value="Start Over"
id="btnStartOver" />

Many browsers render new lines in the HTML codes as whitespaces in the
rendered view. The reason is that in a block of text, when you have a new
line in the text, the browser wants to separate the words. Unfortunately,
it also often creates unwanted white spaces when you want your HTML code
to be nicely formatted.

To avoid this, the only certain way is to write
</tr></table><input type="submit"
name="btnStartOver"
value="Start Over"
id="btnStartOver" />

HTH,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch

Apr 19 '07 #4
H5,

Don Miller wrote:
Thanks, I didn't know (or expect) that. I guess that also means that I can't
include new lines in my ASP.NET code (for coding formatting) but should make
sure all tags are end-to-end.
In most cases, it doesn't matter, because the white spaces are not
visible. It does matter, however, when you have, for example, an image
in a DIV, and the DIV must "hug" the image as tightly as possible

So, generally, you may format your code as you wish, even with
indentation, new lines, etc... but in cases where white spaces suddenly
appear in the rendered view, then it's a good idea to append the tags
without new lines in between (only where necessary).

HTH,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Apr 19 '07 #5

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

Similar topics

0
by: SteveJ | last post by:
All, Can someone help me solve the next step. First of all let me say I'm new to php. I pieced the following code together from samples I found on the net and a book I bought called PHP...
5
by: nivas.meda | last post by:
Hi, I have an excel sheet with a graph and cells.If i change the value in the excel cells the graph will reflect.Now i am going to implement this functionality in html page.I successfully saved...
7
by: Sally | last post by:
In a subform that has no records, what is the white area? If a subform has records and you scroll the records, what is the white area after the last record? I would like to be able to click in...
2
by: KathyB | last post by:
Hi, I have the following script in an aspx html: <script language="javascript"> function pop_window() { var confirmWin = null; confirmWin = window.open('Scanned.aspx', 'SerialNumbers',...
10
by: Angel | last post by:
I want to concat a space in an HTML Control's innerText property. here is a sample code Dim celCreate As New HtmlControls.HtmlTableCell() celCreate.innerText = " TEST" When the page is...
3
by: Steven | last post by:
Hi, There are a lot of white space inside each table field after getting Access DB created with importation from excel file. Then the table and forms/reports are looking bad. Is there a way...
18
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale the same. I have discovered, to my chagrin,...
1
by: since | last post by:
I figured I would post my solution to the following. Resizable column tables. Search and replace values in a table. (IE only) Scrollable tables. Sortable tables. It is based on a lot...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
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...
0
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.