TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
First Last
NA
648
72.4k
Asp.net mvc - how to show rich text without the html tags?
Aug 24 2020 12:54 PM
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
; }
}
}
Reply
Answers (
1
)
Bootstrap Gridllines Center image
I'm getting this error while updating the db