partialviews

How to use anonymous list as model in an ASP.NET MVC partial view?

丶灬走出姿态 提交于 2019-12-09 03:29:26
问题 I have a list of Contact objects, from which, I just want a subset of attributes. So I used LINQ projection to create an anonymous list and I passed that to a partial view. But when I use that list in partial view, compiler says that it doesn't have those attributes. I tried the simplest case as follow, but still I have no chance to use an anonymous object or list in a partial view. var model = new { FirstName = "Saeed", LastName = "Neamati" }; return PartialView(model); And inside partial

ASP.NET MVC Partial View with Form

左心房为你撑大大i 提交于 2019-12-08 01:20:43
问题 I have a scenario I want to use a partial view but I'm having issues with it passing data to the controller. Here is a basic example of what I'm trying to do. Objects: Customer Order A Customer has an IList<Order> on it. I want the partial view to allow the user to edit the information. I can get the data to display but when the form posts the list under the Customer object is null. I have also attempted to use a seperate form in my partial view. When I do this if I create paramenters on the

How to use anonymous list as model in an ASP.NET MVC partial view?

随声附和 提交于 2019-12-01 16:43:48
I have a list of Contact objects, from which, I just want a subset of attributes. So I used LINQ projection to create an anonymous list and I passed that to a partial view. But when I use that list in partial view, compiler says that it doesn't have those attributes. I tried the simplest case as follow, but still I have no chance to use an anonymous object or list in a partial view. var model = new { FirstName = "Saeed", LastName = "Neamati" }; return PartialView(model); And inside partial view, I have: <h1>Your name is @Model.FirstName @Model.LastName<h1> But it says that @Model doesn't have