I have a database column called Template that saves this html content :
"
@section test{}
<div class="row" style="width:800px; margin:0 auto;">
<div class="col-md-4" style="width:800px; margin:0 auto;">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
</div>
</div>
<div class="row" style="width:800px; margin:0 auto;">
<div class="col-md-4" style="width:800px; margin:0 auto;">
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
</div>
</div>
"
This is the view that reads and translates this html :
@model CMSFC.Models.Page
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
@section test{
<p>section test </p>
}
@{
if (Model.Template != null)
{
@Html.Raw(Model.Template)
}
}
And this is the Layout view :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My ASP.NET Application</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
@* @Html.ActionLink("Application name", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })*@
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>@Html.ActionLink("Index", "Index", "Home")</li>
<li>@Html.ActionLink("About", "About", "Home")</li>
<li>@Html.ActionLink("Contact", "Contact", "Home")</li>
<li>@Html.ActionLink("News", "Index", "ContentHtml")</li>
@if (User.Identity.IsAuthenticated)
{
if (User.IsInRole("Admin") || User.IsInRole("Guest"))
{
<li>@Html.ActionLink("PageConfig", "Index", "PageConfigs")</li>
<li>@Html.ActionLink("Pages", "Index", "Pages")</li>
}
}
</ul>
@Html.Partial("_LoginPartial")
</div>
</div>
</div>
@* <div id="test">
@if (IsSectionDefined("test"))
{
@RenderSection("test")
}
</div>*@
<div class="container body-content">
@RenderBody()
<hr />
<footer>
<p></p>
</footer>
</div>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
</body>
</html>
Whta i want is , that the value of
@section test{
<p>section test </p>
}
, so this paragraph to show inside
the test section defined into the
column Template content :
@section test{}
<div class="row" style="width:800px; margin:0 auto;">
<div class="col-md-4" style="width:800px; margin:0 auto;">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
</div>
And then , have a result like this :
section test
1
2
3
4
5
6
7
8
What I have tried:
------------------------------------------------