Hello,
I am new for razor view design in MVC. i know asp.net aspx design very well.
in my aspx web page ,
I use one column from database . that column has content inside the html. like below
column name : gethtml
i do select query : select gethtml from employee
gethtml column contains html stuff
gethtml
********
<head>
<style type="text/css">
p.MsoNormal
{margin-top:0in;
margin-right:0in;
margin-bottom:10.0pt;
margin-left:0in;
line-height:115%;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
}
</style>
</head>
About Lee's Tools<o:p xmlns:o="#unknown">
MVC is one of three ASP.NET programming models. MVC is a framework for building web applications using a MVC (Model View Controller) design: The Model represents the application core (for instance a list of database records).
aspx:
<asp:Label id="lblaboutus" runat="server">
aspx.cs
using (SqlConnection con = new SqlConnection(connstr))
{
con.Open();
SqlCommand cmd = new SqlCommand("select gethtml from employee ", con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
string straboutus = dr["gethtml"].ToString().Trim();
lblaboutus.Text = straboutus;
}
}
that is it.
if i run the project, it shows only content on the browser. like below
MVC is one of three ASP.NET programming models. MVC is a framework for building web applications using a MVC (Model View Controller) design: The Model represents the application core (for instance a list of database records).
can you see html script got avoided once run?
the above content is not showing with html script right? like that i need to show in MVC project where i use razor view.
i do not know how to use razor view to show only content. right now i use @Html.DisplayFor(model=>model.html) in the about.cshtml view. like below
about.cshtml
**************
@model ViewModel.aboutusprop
@{
ViewBag.Title = "about";
}
about
@Html.DisplayFor(model=>model.html)
|
after run the project what it does, it shows content over the browser with html script as it is in database. like below
<head>
<style type="text/css">
p.MsoNormal
{margin-top:0in;
margin-right:0in;
margin-bottom:10.0pt;
margin-left:0in;
line-height:115%;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
}
</style>
</head>
About Lee's Tools<o:p xmlns:o="#unknown">
MVC is one of three ASP.NET programming models. MVC is a framework for building web applications using a MVC (Model View Controller) design: The Model represents the application core (for instance a list of database records).
Note : in DB itself i can insert only content and show But that column is being inserted from ERP not from front end and also that column has been using by various language (mobile app, php , .net)..
aspx Label control is able to show only content without html by default. but razor view shows native column value (content with html script).
how to get only content in razor view?
help needed.