Retain Whitespaces
am 06.01.2007 17:04:44 von rn5a
When a Button is clicked in a Form, the JavaScript 'prompt' dialog
pops-up for users to enter any text. When the user clicks OK in the
prompt dialog, the text is populated in a TextBox & the Form posts. I
then retrieve the text using Request.Form.
The problem I am facing is in retaining whitespaces in the text the
user has entered. Assume that the user has entered the following text
in the JavaScript prompt dialog (note the whitespaces in the string):
"abc def ghi jkl"
The double quotes have been added just to show where the string ends;
they aren't a part of the string.
Now when I retrieve the string using Request.Form, this is what I get
(once again please neglect the double quotes):
"abc def ghi jkl"
i.e. irrespective of the number of whitespaces a user has inserted in
between the words in the JavaScript prompt dialog, Request.Form always
replaces all the whitespaces in between the various words in the string
with a single whitespace.
How do I ensure that the whitespaces entered by the user in the
JavaScript prompt dialog are retained by ASP?
Re: Retain Whitespaces
am 06.01.2007 21:26:07 von Adrienne Boswell
Gazing into my crystal ball I observed rn5a@rediffmail.com writing in
news:1168099484.401603.19230@s34g2000cwa.googlegroups.com:
> When a Button is clicked in a Form, the JavaScript 'prompt' dialog
> pops-up for users to enter any text. When the user clicks OK in the
> prompt dialog, the text is populated in a TextBox & the Form posts. I
> then retrieve the text using Request.Form.
>
> The problem I am facing is in retaining whitespaces in the text the
> user has entered. Assume that the user has entered the following text
> in the JavaScript prompt dialog (note the whitespaces in the string):
>
> "abc def ghi jkl"
>
> The double quotes have been added just to show where the string ends;
> they aren't a part of the string.
>
> Now when I retrieve the string using Request.Form, this is what I get
> (once again please neglect the double quotes):
>
> "abc def ghi jkl"
>
> i.e. irrespective of the number of whitespaces a user has inserted in
> between the words in the JavaScript prompt dialog, Request.Form always
> replaces all the whitespaces in between the various words in the
string
> with a single whitespace.
>
> How do I ensure that the whitespaces entered by the user in the
> JavaScript prompt dialog are retained by ASP?
>
>
Possibly having something to do with the fact that HTML collapses white
space. You could _try_ using style="white-space:pre"
[http://www.w3.org/TR/REC-CSS2/text.html#propdef-white-space ] in the
input element to retain it.
--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share