Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 21st, 2005, 11:17 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 428
Thanks: 57
Thanked 2 Times in 2 Posts
Default Calc TEXTAREA ROWS & COLS based on Font

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...





Similar Threads
Thread Thread Starter Forum Replies Last Post
can I filter rows based on this type of constraint callagga SQL Language 2 August 21st, 2008 04:31 PM
new table cols per record, paging, & select scottiegirl PHP Databases 5 June 21st, 2006 12:29 PM
Rows and Cols Stuff : MSHFlexGrid davekrunal46 VB How-To 1 December 2nd, 2005 01:21 AM
select rows based on a criteria and paste ashu_gupta75 Excel VBA 2 July 30th, 2004 01:32 AM
Looking for Datagrid Cols&Columns reyboy Pro VB.NET 2002/2003 1 May 25th, 2004 08:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.