0

In my MVC 3 application i need to be able to edit text with formatting (ex bold text, linebreaks eks.), and send that edited text to a pdf document. What i want is to put that formated text inside of a MSSQL DB, and be able to retrive it when needed.

Right now i am stuck at basics, when i am saving text to DB, db returns a long text string instead of formated text. Are there any other approaches of doing it?

For formatting i am using CKeditor library.

Maybe there are easier ways of doing it?

1 Answer 1

1

if i am not wrong you can use html.raw helper to get the string in html . then store it in database. but using html.Raw, it will lead to security loops. user may do XSS attacks. you can use @Html.Raw(), with AntiForgeryTokens.

var someText = "<b>Hello World</b> blahblah"; 
@Html.Raw(someText);

Html.Raw() , Html.AntiForgeryToken

Sign up to request clarification or add additional context in comments.

2 Comments

is it smart to save it to Varchar in DB? or should i use something else?
it will return as HtmlString. so you need to assign HtmlString to your POCO objects

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.