Click here to Skip to main content
15,878,748 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I store some Html code in database field[Content] like " it's the image <img src='1.jpg' /> "

Now I want to display the image in my View page,how to do this?

It's the View page

@model MyProjectTest.Models.Article

@{ViewBag.Title ="Article";}

@Model.Content //There must display a image

It does not display a image in my page but a string "it's the image <img src='1.jpg' /> "

How to do this ? Thanks for help!
Posted

1 solution

Use:
C#
@Html.Raw(Model.Content)

And/Or use
C#
[DataType(DataType.Html)]

attribute for Content field
 
Share this answer
 
v2

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