无法访问控制器 - MVC 5中的模型属性

时间:2017-01-29 21:37:21

标签: kendo-ui asp.net-mvc-5 kendo-editor

我对MVC很新。试图实现Kendo编辑器功能。我在SQL Server中有一个存储过程,它返回保存的响应类型为string。在后端,它与标签一起保存为html内容。我创建了一个具有以下属性的模型。我试图在控制器中使用相同的属性,但不知何故,我无法访问控制器中的属性不知道为什么。有人能指出我正确的方向吗?提前谢谢。

型号:

public class LargetextQuestion
{
    [AllowHtml]
    public string Response { get; set; }
}

控制器:

 [HttpGet]
        public ActionResult Largetext()
        {


            HsipLargetextQuestionViewModel vm = new HsipLargetextQuestionViewModel();

            var result = hsiplargetextquestionrepository.GetLargeTextdata(cRegion, cStateCode, nFY, reportId, sectionId, subsectionId, displayNumber, questionNumber, questionPartNumber, userId);


            vm.Response = result;

            return View(vm);

[HttpPost]

    public ActionResult Largetext(HsipLargetextQuestionViewModel model)
    {
        try
        {


          hsiplargetextquestionrepository.SaveLargetextResponse(cRegion, cStateCode, nFY, reportId, sectionId, subsectionId, displayNumber, questionNumber, questionPartNumber, responseString, userId);

            return Content("Saved");
        }

        catch (Exception e)
        {
            return null;
        }
    }

视图模型:

 private IHsipLargetextQuestionsrepository hsiplargetextquestionrepository;

        #region Properties
        [Required]
        [AllowHtml]
        [MaxLength(500, ErrorMessage = "You must enter less than 500 characters.")]
        public  string Response { get; set; }
        public decimal QuestionNumber { get; set; }
        #endregion


        public HsipLargetextQuestionViewModel()
        { }

        public HsipLargetextQuestionViewModel(IHsipLargetextQuestionsrepository repo)
        {
            this.hsiplargetextquestionrepository = repo;


        }

当我执行保存时,记录不会保存并更新到数据库。有人可以指出我正确的方向。

谢谢你, 哈

0 个答案:

没有答案