Set width dynamically for textbox based on length

  • Thread starter Thread starter takilroy
  • Start date Start date
T

takilroy

Hi,

I would like to set the width of a textbox from the server in an aspx
form. I change the contents of the textbox from the server and would
like to change the width accordingly. I know there is code out there
to use creategraphics to do this, but it will not work for aspx files.
It seems like such a simple thing. Does anyone have any code snippets
they would like to share?

Thanks,
Teresa
 
there is no perfect solution, as the dom does not expose enough info to do
it in client script. the best you can do is specify the width in em(s) or
pt(s) which are relative to the fontsize rather than pixels (which isn't).
as most fonts are proportional you can only estimate.

-- bruce (sqlwork.com)
 
Back
Top