i want to display html tags which are in my database to a html webpage. Example:
this is the first post
(with the p tags) - this is stored in database with datatype of varchar(max). when i display this on webpage it displays it but not in html just in text. what am i doing wrong? When i inspect the element i see this <p>this is the first post</p>CodePudding user response:
I believe you need to encapsulate your item with Html.Raw() as in for example:
@model IEnumerable<SOL.Models.Myhtmls>
@foreach (var item in Model)
{
@Html.Raw(item.tag) //where tag is your model's property
}