在模型中使用[allowhtml]属性时,如何在SQL Server中使用break行保存HTML代码标记 [英] How to save HTML code tag with breaks line in SQL server when using [allowhtml] attribute in model

查看:63
本文介绍了在模型中使用[allowhtml]属性时,如何在SQL Server中使用break行保存HTML代码标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在sql server上使用换行符保存下面的代码:

I want to save below code with line breaks on sql server :

<code>
public static void main()
{
      Console.WriteLine("Hello");
}
</code>



用于保存高级代码,我的模型属性应具有[AllowHtml]属性。我的模型具有以下属性:


for save upper code, my model property should have [AllowHtml] attribute. my model has this attribute:

public class MyModel
{
  [AllowHtml]
  [UIHint("RichEditor")]
  public string Content { get; set; }
}



在sql server中保存html代码标签时,结果是下面的代码保存在数据库中并且换行中断了:


when saving html code tag in sql server, result is that below code save in database and line breaks ingnored :

<code>public static void main(){Console.WriteLine("Hello");}</code>



我使用的是asp.net mvc。有人可以帮帮我吗?



我尝试了什么:



没什么......不知道....................


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

What I have tried:

Nothing...no idea....................

推荐答案

也许不是......取决于什么终端用户正在使用换行符 - OS&浏览器可以使用不同类型。有3种有效类型: CR LF CRLF 。迭代字符串中的字符并检查。
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.


这篇关于在模型中使用[allowhtml]属性时,如何在SQL Server中使用break行保存HTML代码标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆