What is View models

 Posted by Jitendrasoft09 on 7/31/2013 | Category: .NET Framework Interview questions | Views: 1983 | Points: 40
Answer:

ViewData.Model property is conceptually no different from ViewData["Model"], it
promotes the model to a first-class citizen and recognizes it as more important than the other data that might be in the request.

Model-
public class CompanyInfo

{
public string Name { get; set; }
public string Description { get; set; }
}


View
@{ var company = (CompanyInfo)ViewData.Model; }


Here we have CompanyInfo is defined in a model and accessing into view using ViewData.Model/


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response

More Interview Questions by Jitendrasoft09