show borders on empty table cells

 

if you use a tabel with borders to display your data you might have the problem that browsers do not display borders for table cells which are absolutely empty. they will look like:

 

text text text
text text
text text text

instead of

text text text
text   text
text text text

 

if you insert a new table in Ultradev it will always put non breaking spaces ( ) into the cells to avoid this. however, if you drag an item from the databindings to the cell the non breaking space gets replaced by this item and if the field for this cell has no value you get borderless cells.

a simple trick to avoid this is to enter a non breaking space manually before or after the data item (Ctr+Shift+Space).

a more elegant way is to insert a little script that checks if the value is empty and inserts the   if this is the case.

 

your normal item looks like

<%=(Recordset1.Fields.Item("myField").Value)%>

for VBScript try the following code

<%
If (NOT Recordset1.Fields.Item("myField").Value = "") then
Response.Write(Recordset1.Fields.Item("myField").Value)
Else
Response.Write("&nbs" & "p;")
End if
%>

for JavaScript try this:

<%
if (!Recordset1.Fields.Item("myField").Value) {
Response.Write("&nbs"+"p;");
}
else {
Response.Write(Recordset1.Fields.Item("myField").Value);
}
%>

you might wonder why i used "&nbs"+"p;" instead of "&nbsp;". this is due to a slight Ultradev bug. if you enter "&nbsp;" Ultradev unfortunately interprets this and creates " " which is useless. however, the workaround is very simple: break up the string so it does not make sense to Ultradev.

 

 


 

1