Search

Thursday, December 10, 2015
0 comments

How to pass data from controller to view in ASP.NET MVC

9:44 PMThursday, December 10, 2015
If you want to pass value from controller to view in asp.net MVC, we have two methods. The first method of it is ViewBag and last is ViewData, both are used to pass data from controller to view. ViewBag object creates a dynamic variable and ViewData creates a dynamic key like ViewState in ASP.NET.  Learn, How to use ViewBag in MVC for single variable as well as List<String> type variable. 


In controller class, we used ViewBag.Dynamic_variable = "Value" and in View we used @ViewBag.Dynamic_Variable_Name. Also, learn how to pass value from controller to view using ViewData.



Both objects doesnot generate compile time error.

Protected by Copyscape Online Copyright Protection Software

0 comments :

Post a Comment

 
Toggle Footer
Top