asp.net mvc4 razor pass view model to helper
问题 I want to pass view model to my html helper/ I have tried public static string GenerateFullTable(this HtmlHelper helper, IEnumerable<CarsViewModel> model) { But I dont know which model would be. Does it possible to make universal helper which gets would get different view models? 回答1: Yes, it's called Generics. http://msdn.microsoft.com/en-us/library/ms379564(v=vs.80).aspx Edit: Here's one example... public static string GenerateFullTable<T>(this HtmlHelper helper, IEnumerable<T> model) { ...