Controlling the Height of HTML Tables that Contain Forms
When working with HTML forms and ASP the order of the tags CAN and WILL make a difference! This article details some traps that HTML newbies can run into when designing ASP pages.
AI
AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Source Code
<p><font face="Verdana">While trying to create a toolbar using HTML forms in an
ASP page, I created the HTML form within a table using the following code:<br>
<br>
</font></p>
<table border="0" cellPadding="0" cellSpacing="0" width="100%">
<tbody>
<tr>
<td bgColor="#d0d5df" width="100%"><font face="Verdana"><font size="2"><Table
border="0" cellspacing="0" cellpadding="0"
style="HEIGHT: 30px; WIDTH: 100%"><br>
<tr ><br>
<td bgcolor="navy"
width="1%"><br>
</font> <font size="2"></td><br>
<td bgcolor="navy"
width="99%" align="left" valign="center"><br>
<form method="POST" action="<%= strURL%>"
id=form1 name=form1><br>
<input type="submit" value="<%= strEditBtnCaption
%>" name="cmdEdit"><br>
</font> <font size="2">
</form><br>
</td><br>
</tr><br>
</Table></font></font></td>
</tr>
</tbody>
</table>
<p> </p>
<p><font face="Verdana"> The code worked but I ended up with a
blue background that was "taller" than I wanted it to be, as shown in
the screen print below.</font></p>
<p align="center"><font face="Verdana"><img border="0" src="http://www.planet-source-code.com/vb/tutorial/asp/images/FormInsideTable.jpg" width="419" height="307"></font></p>
<p><font face="Verdana"> I tried changing the <TABLE>,
<TR>, and <TD> heights but nothing worked!!!</font></p>
<p><font face="Verdana"> Finally, I decided to move the
<FORM> tags outside of the <TABLE> tags and this is what happened:</font></p>
<table border="0" cellPadding="0" cellSpacing="0" width="100%">
<tbody>
<tr>
<td bgColor="#d0d5df" width="100%"><font face="Verdana"><font size="2"><br>
<form method="POST" action="<%=
strURL%>" id=form1 name=form1><br>
<Table
border="0" cellspacing="0" cellpadding="0"
style="HEIGHT: 30px; WIDTH: 100%"><br>
<tr
><br>
<td bgcolor="navy" width="1%"><br>
</td><br>
<td bgcolor="navy" width="99%"
align="left" valign="center"><br>
<input type="submit" value="<%= strEditBtnCaption
%>" name="cmdEdit"><br>
</font> <font size="2"></td><br>
</tr><br>
</font> <font size="2"></Table><br>
</font> <font size="2"></form></font></font></td>
</tr>
</tbody>
</table>
<p align="center"><font face="Verdana"> It produced
different/better results!!! Now I can control the height of the blue
background to look the way I want it to look!!!<br>
<br>
<br>
<img border="0" src="http://www.planet-source-code.com/vb/tutorial/asp/images/tableInsideForm.jpg" width="419" height="307"></font></p>
The code given below sends AT commands to a mobile phone connected to the computer via the COM port and sends a SMS message to the number specified by the user.
using System;
using System.Collections.Generic;
using System.Text;
using System.IO.Ports;
using System.Threading;
namespace ConsoleApplication1
{
class Program
{
static AutoResetEvent readNow = new AutoResetEvent(false);
static SerialPort port;
static void Main(string[] args)
{
try
{
Console.Write("Enter the port name your phone is connected to: ");
string portname = Console.ReadLine();
port = EstablishConnection(portname);
string recievedData = ExecuteCommand("AT", 300);
recievedData = ExecuteCommand("AT+CMGF=1", 300);
Console.Write("Enter the phone number you want to send message to: ");
String phoneNumber = Console.ReadLine();
String command = "AT+CMGS=\"" + phoneNumber + "\"";
Console.Write("Enter the message you want to send: ");
recievedData = ExecuteCommand(command, 300);
string message = Console.ReadLine();
command = message + char.ConvertFromUtf32(26) + "\r";
recievedData = ExecuteCommand(command, 300);
if (recievedData.EndsWith("\r\nOK\r\n"))
recievedData = "Message sent successfully";
if (recievedData.Contains("ERROR"))
{
string recievedError = recievedData;
recievedError = recievedError.Trim();
recievedData = "Following error occured while sending the message" + recievedError;
}
Console.WriteLine(recievedData);
Console.ReadLine();
}
catch (Exception e)
{
Console.WriteLine("Error Message: "+e.Message.Trim()+"\r\nHit any key to Exit");
Console.ReadLine();
}
finally
{
if (port != null)
{
port.Close();
port.DataReceived -= new SerialDataReceivedEventHandler(DataReceived);
port = null;
}
}
}
static string ExecuteCommand(string command,int timeout)
{
port.DiscardInBuffer();
port.DiscardOutBuffer();
readNow.Reset();
port.Write(command+"\r");
string recieved = receive(timeout);
return recieved;
}
static string receive(int timeout)
{
string buffer = string.Empty;
do
{
if (readNow.WaitOne(timeout, false))
{
string t = port.ReadExisting();
buffer += t;
}
}
while (!buffer.EndsWith("\r\nOK\r\n") && !buffer.EndsWith("\r\n> ") && !buffer.Contains("ERROR"));
return buffer;
}
static SerialPort EstablishConnection(string portName)
{
SerialPort port = new SerialPort();
port.PortName = portName;
port.BaudRate = 19200;
port.DataBits = 8;
port.StopBits = StopBits.One;
port.Parity = Parity.None;
port.ReadTimeout = 300;
port.WriteTimeout = 300;
port.Encoding = Encoding.GetEncoding("iso-8859-1");
port.DataReceived += new SerialDataReceivedEventHandler(DataReceived);
port.Open();
port.DtrEnable = true;
port.RtsEnable = true;
return port;
}
static void DataReceived(object sender, SerialDataReceivedEventArgs e)
{
if (e.EventType == SerialData.Chars)
readNow.Set();
}
}
}
Original Comments (3)
Recovered from Wayback Machine