1

I have read several topics (like this one: Database field containing HTML display raw text) but somehow can't find the solution.

I have this line:

@Html.DisplayFor(model => model.Content) // this works, but shows unparsed html

But this does not work:

@Html.Raw(model.Content)

I get an The name 'model' does not exist in the current context error. Since I used database first. I generated my model from the *.edmx file. So Content is of type String.

thanks in advance!

ps. my first non-webform project.

0

1 Answer 1

3

You want to use Model rather than model:

 @Html.Raw(Model.Content)

When using @Html.DisplayFor the model is automatically passed in and given the name you assigned to it, in this case model.

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

2 Comments

Thanks! (have to wait 7 minutes before I can accept your anwser)
ps. why does visual studio generate every property with this linq?

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.