Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6021517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:43:28+00:00 2026-05-23T03:43:28+00:00

I really don’t think this has anything to do with ASP.NET MVC 2 itself,

  • 0

I really don’t think this has anything to do with ASP.NET MVC 2 itself, but I mention that as it is the environment I am working in and at least one aspect of my problem is connected to the way MVC 2 behaves. My problem is this:

I have a TEXTAREA element on a form that allows multiple lines of data to be entered. When the form is posted back to the server (using IE8), I can see that the data is formatted as “A\n\rB\n\rC\n\rD”. I then save this data to a database table where it appears exactly the same way. However, when I come back to the page at a later time, loading the data from the database and setting it as the value of the TEXTAREA element, it displays the “\n\r” as literal characters instead of line breaks!

As a side note, with ASP.NET MVC, if I follow the standard if (!ModelState.IsValid) return View(viewModel); approach, the TEXTAREA displays fine when re-rendering the same form due to a validation error. This tells me that the problem must be related to persisting and retrieving the data to/from the (SQL Server) database.

I have the same display problem in FireFox and Chrome with the notable difference being that the data is formatted as “A\r\nB\r\nC\r\nD” when submitted from those browsers.

With these differences in behavior, how can I handle persisting multi-line data from a TEXTAREA that will render properly in ALL browsers?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:43:29+00:00Added an answer on May 23, 2026 at 3:43 am

    I haven’t found an actual solution but have implemented a work around.

    When I set the property on my object to the submitted value from the TEXTAREA, I perform a regular expression replacement on the text to convert whatever characters are returned from the browser to ‘\n’ which appears to work as a line break in all browsers I checked (IE8, Chrome & FireFox). Here is the code I’m using (in .NET):

    cleanValue = Regex.Replace(value, "(\\n|\\\\n|\\r|\\\\r)+", "\n", RegexOptions.IgnoreCase);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am re-designing an application for a ASP.NET CMS that I really don't like.
This question is coded in pseudo-PHP, but I really don't mind what language I
I really don't know how to describe it, but if you understood it and
I have the following markup for buttons (can be changed, but I really don't
I don't really FEEL CSS and it doesn't always work as I think it
I really don't understand this. I downloaded the recent version of xCode 3.2.5 and
I really don't want to, but I have to emulate COM logic in my
I am persuaded of usefulness of unit tests but I really don't understand rules
I recieve some information about using binding source but I really don't understand explicitly
I really don't like the VS2008 Start Page. I don't need the RSS reader,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.