3 Answers. Platform Model. Step 6. Complete Practical Example View Model View Model is nothing, just a class that calls all models in a single class and then returns values to view pages. View Model is nothing, just a class that calls all models in a single class and then returns values to view pages. Set values to Model in MVC @model FirstMVCDemo.ViewModels.EmployeeDetailsViewModel. First you could used @model.name to assign value to textbox. How to bind a model to a partial view in ASP.NET MVC? define the associated view by replacing the content of the . We have to assign the value to a global scoped javascipt variable and then use this variable within all code block of your .cshtml and .js files. public ActionResult GetBlogComment () { ViewData [ "Blog"] = GetBlogModel (); ViewData [ "Comments"] = GetCommentModel (); return View (); } Now change your view ( GetBlogComment.cshtml) according to view Data as below: Run the application and we will get the same result as in approach 1. You can see the concept of ViewModel in the image below. ViewModel - Display Multiple Model Values into Views in ASP.NET MVC 5 In this chapter, you will learn: 1. var userObj = @Model; When you assign a c# object to javascript variable the value of the .ToString () of that oject will be assigned. Code: @model FirstMVCDemo.ViewModels.PlatformTutorialsViewModel @ { Layout = null; } ProductVM model = new ProductVM () { UnitPrice = 100M }; return View (model); If the value is a 'default' value that applies to all instances, you can also set its value in a parameter-less constructor. You need to set the value of the property in the model before you pass the model to the view. Create or Use Hidden Fields in Asp.Net MVC with HTML Helpers ... - Tutlane Now, click OK. Then, select Empty MVC template and click OK to create the project. Again, you can have your own function to populate that list in any way you like. 2 Wrapping object assignment in quotes We are using Interface as model in mvc. assign value to model in view mvc - toneaudiomagazine.com In Solution Explorer, right-click the Controllers folder and then click Add, then Controller. How to assign value to input field