Professional Documents
Culture Documents
This article deals with how we can pass data from a controller to view.For that we can use either
ViewData or ViewBag.
Let us see how we can implement it...
Adding Controller
1. First of all, we can add a control to the project as we already seen.
1. Double click on the controller and add the following contents to controller.
Adding View
2. Saving and run the application, we will obtain the result. ie, it shows the current system date
and time.
Using ViewBag
1. Likewise we can also use ViewBag instead of ViewData.Same procedure repeat again.
2. Double click on the controller and add the following contents to controller.
3. Also by Double click on the view and add the following contents to view.
4. Then run the project and it will show the current system date and time.