Pls, explain this line (Am confused)
ASP.NET MVC also provides the ability to pass strongly typed data or objects to a view template.
What is Strongly Typed Data?
:)
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Ramesh MaruthiRank #937 · 2.2K reputationPosted Aug 11, 2014, 6:13 AM EDT
http://blog.stevensanderson.com/2008/02/21/aspnet-mvc-making-strongly-typed-viewpages-more-easily/
http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/strongly-typed-views-in-mvc/
In this link once look at from this heading
Strongly Typed Models and the @model Keyword
http://www.asp.net/mvc/tutorials/mvc-5/introduction/accessing-your-models-data-from-a-controllerRick explained in a detail way :)
Abhishek JaiswalRank #126 · 17.5K reputationPosted Aug 11, 2014, 11:40 AM EDT
the above mentioned line is from the heading u did added in ur reply. :D
i just want explanation of that line in brief.
:)
Ramesh MaruthiRank #937 · 2.2K reputationPosted Aug 11, 2014, 11:47 AM EDT
Def2 :A Strongly Typed view means it has a ViewModel associated to it that the controller is passing to it and all the elements in that View can use those ViewModel properties
You can have strongly typed partials as well. Meaning that piece of Html needs specific data so you type it to a certain ViewModel
Here is an example of a Strongly Typed View
@model SomeViewModel
...// all the html comes after
A view that is strongly typed have a @model SomeViewModel line
Here's one that renders a strongly typed View
public ActionResult Index() {
var model = new SomeViewModel();
return View(model);
}
And the view makes use of that ViewModel by having the @model SomeViewModel at the top of the file.
So now that the view has a ViewModel I can display elements that are bound to the ViewModel like
@Model.Name
@Model.Location
OR for Controls------
@Html.TextBoxFor(m => m.Name)
@Html.TextBoxFor(m => m.Location)
you can find the brief explanation in that links :)
Alok SaxenaRank #3,748 · 395 reputationPosted Aug 19, 2014, 11:53 PM EDT
Strongly Typed Data is a type tied to Object and Object's properties.
Step-1 Controller
public class DepartmentController : Controller
{
private DepartmentDBContext db = new DepartmentDBContext();
public ActionResult Index()
{
return View(db.Department.ToList());
}
}
Step-2 View
Details
Department Name
@Html.DisplayNameFor(model => model.DepartmentTitle)