我如何使用post方法asp.mvc将数据绑定到模型

时间:2016-12-01 07:37:33

标签: c# asp.net-mvc-4 viewmodel

我的索引视图:包含文本,子文本和结果

            <div class="control-group">
                @Html.LabelFor(m => m.Result, new { @class = "control-label" })
                <div class="controls">
                    @Html.TextBoxFor(m => m.Result, new { @class = "span6" })
                </div>
            </div>

我的家庭控制器有行动指数

[HttpPost]
            public ActionResult Index(HomeViewModel vm)
            {
                var input = vm.Text;
                var subText = vm.SubText;
                IMatchString mString = new MatchStringProvider();
                string result = mString.MatchString(input, subText).ToString();
                vm.Result = String.IsNullOrEmpty(result) ? "no matches" : result;

                return View(vm);
            }

当我发布数据到动作索引并返回视图但结果的文本框不显示结果我做错了什么,帮我解决这个问题

0 个答案:

没有答案