I don't think storing data encoded in a database is a good idea.
Using ASPNET / MVC C # (with Razor) to bind information from a database to a text area value. I use C # and had to do something like this server side when installing the observable.
An example of replaced charcters, so value binding works correctly.
model.Description = ko.observable( @html.Raw( Model.Description.Replace("\"", "\\\"") .Replace("'", "\\\'") .Replace(Environment.NewLine, "\\r\\n") ) );
The extension method makes binding more enjoyable.
public static IHtmlString HtmlEscape(this String str) { if (String.IsNullOrEmpty(str)) return new HtmlString(""); var html = ((System.Web.Mvc.WebViewPage) WebPageContext.Current.Page).Html; return html.Raw( str.Replace("\"", "\\\"") .Replace("'", "\\\'") .Replace(Environment.NewLine, "\\r\\n")); }
And binding
Description: ko.observable("@(Model.Description.HtmlEscape())");
It worked for me.
source share