Click here to Skip to main content
16,015,218 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,
I have HTML form, contains a few text area fields, no problem in submitting the form data to an sql server, then retrieving this data again, no problem..
The problem occurs when I use the 'ENTER' keyboard button while I'm typing the text in the text area, the data is submitted normally in the sql database table, BUT can't be retrieved..
When I deleted the line break in the database table, it retrieved normally!

What I have tried:

1- I tried to change the textarea tag with input tag, it's not working
2- I tried to change the table column collation, not working
Code:
<span>Improvement</span><br><textarea name='imprv_$x' id='imprvid_$x' oninput='imprvinp()' disabled></textarea><br><div class='editcls'><button type='button' name='' id='' class='ideagenbutcls' onclick='imprvedit_$x()'>Edit</button><input type='submit' name='imprvsave_$x' id='imprvsaveid_$x' value='Save' class='ideagenbutcls' disabled></div>



Any idea?
Thank you in advance
Posted
Updated 16-Nov-22 19:22pm
v3

A string with CR\LF characters in it has no bearing on being retrieved from the database at all.

The problem comes with either you're storing of the data or how you're displaying the data in your HTML page.

CR\LF means nothing to HTML, so there's no line break when the text is rendered by the browser. You have to replace the CR\LR characters in the string with a HTML tag,
, to get the line breaks to render properly.
 
Share this answer
 
v2
Comments
Member 14819235 16-Nov-22 19:32pm    
I'm sorry, what CR\LR stands for?
Dave Kreskowiak 16-Nov-22 19:36pm    
Carriage Return/Line Feed. It's what denotes a new line in Windows.
Member 14819235 16-Nov-22 19:40pm    
Thanks,
It's a user data entry form, how can I control or use any HTML tag in it? here's the code of the textarea with edit and save buttons
ImprovementEdit
Member 14819235 16-Nov-22 19:41pm    
ImprovementEdit
Member 14819235 16-Nov-22 19:43pm    
I included my code to my question
Quote:
Thanks, It's a user data entry form, how can I control or use any HTML tag in it? here's the code of the textarea with edit and save buttons ImprovementEdit
Try:
C#
string result = inputString.Replace("\n", "<br />");
 
Share this answer
 
Comments
Member 14819235 17-Nov-22 11:39am    
Thanks for your answer, I'll use your idea, here's the code I use for HTML and Javascript:
appears in the user form input, which is not suitable for me
function imprvinp(){
for(var n=1; n<=''; n++){
if (document.getElementById("imprvid_"+n).value.includes("'")){ document.getElementById("imprvid_"+n).value=document.getElementById("imprvid_"+n).value.replace("'", "_"); }
if (document.getElementById("imprvid_"+n).value.includes("\n")){ document.getElementById("imprvid_"+n).value=document.getElementById("imprvid_"+n).value.replace("\n", ""); }
}
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900