I have coded an HTML generator in ASP.NET that builds web pages based on user specifications. It creates a data entry form and the user who defines the form may specify the maximum length of data that may be entered into INPUT/TEXTAREA fields, as well as FONT and character SIZE and the width of the space in which thess fields appear.
In order to make this form look right in the browser and print correctly as well, I need to figure out the COLS and ROWS for the INPUT/TEXTAREA to ensure all of the possible entered text is [u]always</u> visible (no scrolling necesary, ever). In fact, part of the challenge is determining whether I need to use a TEXTAREA rather than INPUT because the field MUST wrap to multiple lines. The calculation must therefore take into consideration the font size, maximum field length, and the space on the page where it will be displayed (inside a variable width TD specified in percentage).
IOW, if the user specifies a 50 byte field and there's enough room in the space available to display the entire field as one row, I'd want to use an INPUT field. If, OTOH, the user specifies a 100 byte value may be entered, and the width of the TD the field will reside in would allow only 25 characters per row using a 20pt Courier font, a TEXTAREA 25 COLS wide and 4 ROWS long is needed in order to input/print the entire value without requiring a scrolling TEXTAREA. But if the available space would only permit 20 characters in 20pt Arial, then COLS should be 20 and ROWS would be 5.
So, is there some way to determine how many ROWS and COLS would be needed in each of these instances (and any other possible combinations) to accomodate all of the possible text that may be entered and thereby create a field which uses all the available space? I've done this in Windows but can't figure out how in a browser. If it makes any difference, I am working strictly in IE, so browser differences are immaterial, and I would prefer a
VB solution, although I can convert from C#, if necessary. TIA...