Click here to Skip to main content
15,918,967 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to save below code with line breaks on sql server :
HTML
<code>
public static void main()
{
      Console.WriteLine("Hello");
}
</code>

for save upper code, my model property should have [AllowHtml] attribute. my model has this attribute:
C#
public class MyModel
{
  [AllowHtml]
  [UIHint("RichEditor")]
  public string Content { get; set; }
}

when saving html code tag in sql server, result is that below code save in database and line breaks ingnored :
HTML
<code>public static void main(){Console.WriteLine("Hello");}</code>

I use asp.net mvc. can anyone help me?

What I have tried:

Nothing...no idea....................
Posted
Updated 5-Mar-17 3:55am
v2

1 solution

Maybe not... Depends on what line breaks are being used by the end user - OS & browser can use different types. There are 3 valid types: CR, LF, CRLF. Iterate the characters in the string and check.
 
Share this answer
 

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