\n not creating linefeed from code behind

Posted on 2005-04-16
Last Modified: 2010-04-23
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?
Question by:mbwatkins
    LVL 13

    Expert Comment

    Can you use vbCRLF

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


    Author Comment

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

    Expert Comment

    I think the points should be refunded and the question should be PAQ'd as the OP answered his own question

    Accepted Solution

    PAQed with points refunded (500)

    Community Support Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now