Translate

Web based MVC

Create an ASP.Net MVC4 ->Internet Application project (VS Express 2012 for web) with Razor view engine.

Model, Controller and View

Creating a database (VS Express 2012 for web)

Right click o App_Data->Add->New item...



Name the database as "TimeSheet.mdf"
 Creating a model

Right-click on the Models folder, Add->New item or ADO.Net Entity Data Model and follow the steps in the below screenshot



(Note: Since many readers form an opinion without leaving one, I make a mention of the "Start_date" and "end_date". The fields may not be necessary as we proceed through this example.)

What is ViewData?

View data is the data returned by the Controller to the View based on the Model. This is usually in the form of ViewBag.

Without the Controller's knowledge, if the View attempts to display a property of the Model, the below exception is thrown.

Controller has no knowledge of the ViewData that is being requested by the View; another possibility for the below error is when the project has not been built after creating the ViewData in the Controller.



No comments: