in my MVC web apps, I need to create a popup window with a Partial view (contains webgrid) in it, The problem is the partial view data did not show on the dialogbox, I only see the title. it seems I have problem with the controller call, as well, please be noted I used dynamic model creation since the model was created dynamically in the controller, not an existing model, no sure how to use this type of model. Thanks for any help, This is my codes: this is button in razor view: this jQuery codes:
$(document).ready(function () {
$("#GetEmp").click(function (event) {
$("#popup").dialog({
width: 200,
hight: 400,
title: 'please select an employee',
modal: true,
open: function (event, ui) {
$(this).load("@Url.Action("Travel", "GetEmployee")");
}
});
});
});
This is controller code:
public class Employee
{
public string EmpName;
public string EmpPhone;
public string EmpNum;
}
[HttpPost]
public ActionResult GetEmployee()
{
List<Employee> Emp = new List<Employee>
{
new Employee { EmpName= "ScottGu", EmpPhone = "23232323", EmpNum="242342"},
new Employee { EmpName = "Scott Hanselman", EmpPhone = "3435353", EmpNum="34535"},
new Employee { EmpName = "Jon Galloway", EmpPhone = "4534535345345",
EmpNum="345353"}
};
return PartialView("_EmpPartial", Emp );
}
And this is Employee partial view: please note, I am using dynamic in model, since the model is created dynamically.
@model dynamic
<ul>
@foreach (var emp in Model) {
<li>
@emp.EmpName
</li>
}
</ul>
Hi, thanks for the quick response, I tried it, Remove [HttpPost] and changed @foreach to @foreach (var emp in Model as List), but the does not compile with a red underline in it. do I have to keep @model dynamic in my partial view?