I DO NOT want to show the html tags in the content to the User. How to I do that?
I have a maintenance app that adds/edits blog content. It has a rich text editor.
When the content is saved in the SQL server database in a column defined as varchar(max), it saves it with html tags.
The edit feature retrieves the entry from the database and shows the html tags.
Now when I want to display the content to the User in a view (.cshtml), I DO NOT want to see the html tags.
Here is the view (not showing all of the code):
- @model GbngWebClient.Models.BlogPublishedByBlogIdVM
- <h2 class="page-header"><span class="blogtitle">@Session["BlogTitle"]</span></h2>
- @{
- Layout = "~/Views/Shared/_LayoutUser.cshtml";
- }
- <div>
- <a href="@Url.Action("LoadDropdownBlogCategorysInBlogsPublished", "BlogPublished")">Return To Select a Blog</a>
- </div>
- <br />
- @if (Model != null)
- {
- @Html.LabelFor(model => model.BlogPublishedByBlogId.CreatedDateTime)
- @Html.TextBoxFor(model => model.BlogPublishedByBlogId.CreatedDateTime, new { @class = "form-control", @disabled = "disabled" })
- @Html.LabelFor(model => model.BlogPublishedByBlogId.ModifiedDateTime)
- @Html.TextBoxFor(model => model.BlogPublishedByBlogId.ModifiedDateTime, new { @class = "form-control", @disabled = "disabled" })
- @Html.DisplayFor(model => model.BlogPublishedByBlogId.BlogContent, new { @class = "form-control blogContent", @disabled = "disabled" })
- }
Here are the models (not showing all of the properties):
- namespace GbngWebClient.Models
- {
- public class BlogPublishedByBlogIdVM
- {
- public BlogPublishedByBlogIdVM()
- {
- this.BlogPublishedByBlogId = new BlogPublishedByBlogId();
- }
- public BlogPublishedByBlogId BlogPublishedByBlogId { get; set; }
- }
- }
- using System;
- using System.ComponentModel.DataAnnotations;
- namespace GbngWebClient.Models
- {
- public class BlogPublishedByBlogId
- {
- [Required]
- [Display(Name = "Content")]
- public string BlogContent { get; set; }
- }
- }