Reputation: 68
SchoolController
schoolBLL content = new schoolBLL ();
DatabaseSchool dbSchool = content.GetSchoolInfoById(LoginStaffId);
if (dbschool != null)
{
string textcontent = dbschool .text_content;
}
class file
public DatabaseSchool GetSchoolInfoById(int StaffId)
{
return SchoolRepo.Find(a => a.schoolcontent_id == StaffId).FirstOrDefault();
}
So, I am trying to display the data in to a HTML page with this tag
How can I pass the value from the controller into the HTML page ?
I already tried to use ViewBag and it doesn't work!
Upvotes: 0
Views: 63
Reputation: 529
For displaying data into an html page try below:
School Controller:
schoolBLL content = new schoolBL();
DatabaseSchool dbSchool = content.GetSchoolInfoById(LoginStaffId);
if(dbschool != null)
{
TempData["textcontent"] = dbschool.text_content;
}
HTML:
<textarea id="txtcontent" class="form-control" rows="20">@TempData["textcontent"]</textarea>
Better to use CSHTML:
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width"/>
<title>Index</title>
</head>
<body>
@Html.TextArea("Content", TempData["textcontent"])
</body>
</html>
Upvotes: 1