• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

\n not creating linefeed from code behind

From code behind I am populating a hidden HTML input with a string containing \n.  onload of the body javascript checks the value of the hidden input and if it does not ="N" then alert what is contained in the hidden input.  The process works fine, showing the alert when appropiate, but the \n is not interpreted as a line feed in the alert, just part of the string.  Do I need escape chars or some such to consume the \n?
  • 2
1 Solution
Corey ScheichDeveloperCommented:
Can you use vbCRLF

"First Line." & vbCRLF & "Second Line"

mbwatkinsAuthor Commented:
I figured this out.  If the string contnents I want to alert is in an HTML control (i.e. input or textarea) javascipt will treat the contents as one big string bypassing the "\n" or other escapes.  I now just response.write from the code behind the message into a javascript var on the page.  When the onload fires it has the contents I want to alert in memory and displays appropiriately.
Corey ScheichDeveloperCommented:
I think the points should be refunded and the question should be PAQ'd as the OP answered his own question
PAQed with points refunded (500)

Community Support Moderator
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now