We have a text box in this we are allowing 100 characters per line and saving to DB. Here our problem is that if a user writes 50 characters, presses enter to insert a newline and then repeats this procedure with 40 then 30 then 20 etc. characters per line it’s saving like continues in single line.
Ex : user enter given following
The integration system test environment
is also the first environment
where testers can simulate real attack
scenarios as can be potentially executed
by a malicious, external or internal user of the application
but when saving into our DB it’s saving like following.
The integration system test environment is also the first environment where testers can simulate real attack scenarios as can be potentially executed by a malicious, external or internal user of the application.
We are disabling by default all html tags only we need to display text as user given by adding automatic “br”.
First of all: The text you get from the text box may contain line breaks and they will be stored in SQL Server, but you won’t see it in the Management Studio. It will appear to be one line even though it isn’t.
I suspect the problem you’re having is that reading the text from the database and displaying it on the web site does not use any line breaks – this is because line breaks are not used in HTML to break lines. The
<br />tag is used to break lines in HTML. So what you’d need to do is:\r\nwith<br />