0

I have a PartialView that should receive a model like:

@model MiniSIGEweb.Models.StudentViewModel

And I have this model as a javascript variable viewModel.selectedStudent:

<script>
        var viewModel = kendo.observable({
            dataSource: dataSource,
            selectedStudent: {},
            /*...*/
        });
    /*...*/
    </script>

How can I pass this variable to the PartialView?

@Html.Partial("_Edit.Mobile", /*Here I should pass the variable*/)

I'm not sure if this is important but I'm appending the StudentViewModelClass:

public class StudentViewModel
    {
        public long Id { get; set; }
        [Required]
        public string Name { get; set; }
        [Required]
        [Range(1, 100)]
        public Nullable<int> Age { get; set; }
        [Required]
        public string Course { get; set; }
        [Required]
        [Display(Name = "School")]
        public string SchoolName { get; set; }
        [Required]
        public string City { get; set; }
        [Required]
        public string Country { get; set; }
        public Nullable<System.DateTime> BuildDate { get; set; }
    }
4

1 回答 1

0

您不能混合使用服务器和客户端代码。我可以给你两种方法来实现它:

  • 使用客户端模板,例如jsrender
  • 使用 Ajax 从服务器加载数据(Action 将返回 PartialViewResult

从您的问题来看,尚不清楚哪个更好。

于 2013-03-21T12:22:27.867 回答