MVC——第一个界面的数据传到第二个界面

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/u012654963/article/details/51115385

    本文介绍了,在MVC中,如何将第一个界面的值在第二个界面显示。

如:

    第一个界面:


    点击下一步后:将课程性质和考核项名称传到下一个界面。

实现过程:

    第一个界面将要传的值,放在url中。

var url ="?courseProperty="+courseProperty+"&assessName="+assessName+"&score="+score;
            $("#addPaper").unbind('click');
            $.post(url, "", function() {
            window.location.href ="../Paper/AssessContent"+url;

    其中coursePropertyassessNamescore的值这样获取的:

var courseProperty =$("#courseProperty").combobox('getText');//后部分可理解为获取控件的值

var assessName =$("#assessName").combobox('getText');//这是获取下拉框值

var score =$("#score").val();//这是获取文本框值

    传过去之后,他首先到Controller中,在相应的方法中,写入获取值的方法:

public ActionResult AssessContent()
         {
             EvalCoursePaperViewModelcourseAssess = new EvalCoursePaperViewModel();
            courseAssess.CourseProperty =Request.QueryString["courseProperty"];//获取传过来的值,放入实体中
            courseAssess.AssessName=Request.QueryString["assessName"];
            ViewData["CourseProperty"] = courseAssess.CourseProperty;//给ViewData赋值
             ViewData["AssessName"] =courseAssess.AssessName;
             return View();
         }


    这样,第二个界面就可以获取了:

<spanstyle="font-size:20px"> 课程性质: @ViewData["CourseProperty"]</span>
        <spanid="coursePropertyName"style="font-size:20px"></span>          
        <spanstyle="font-size:20px">考核项名称: @ViewData["AssessName"]</span>
    效果:



展开阅读全文

MVC 如何获取list界面的值

12-13

下面是一个list列表,在列表中最后一列的数字是可以编辑的,我想点提交把修改后的模型数据在后台保存rnrn@model WebApplication4.Models.BomMappingrnrn@using GridMvc.Html;rnrn@rn ViewBag.Title = "List";rnrnrn Listrnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn @foreach (var c in Model.IrregularTitle)rn rn rn @Html.DisplayFor(modelItem => c)rn rn rn rn 制式rn rn rn 脚数rn rn rn rn @foreach (var item in Model.Irregular)rn rn rn @if (Model.IrregularTitle.Count > 0)rn rn rn @Html.DisplayFor(modelItem => item.Value1)rn rn rn @if (Model.IrregularTitle.Count > 1)rn rn rn @Html.DisplayFor(modelItem => item.Value2)rn rn rn @if (Model.IrregularTitle.Count > 2)rn rn rn @Html.DisplayFor(modelItem => item.Value3)rn rn rn @if (Model.IrregularTitle.Count > 3)rn rn rn @Html.DisplayFor(modelItem => item.Value4)rn rn rn @if (Model.IrregularTitle.Count > 4)rn rn rn @Html.DisplayFor(modelItem => item.Value5)rn rn rn @if (Model.IrregularTitle.Count > 5)rn rn rn @Html.DisplayFor(modelItem => item.Value6)rn rn rn rn @Html.DisplayFor(modelItem => item.ProcessText)rn rn rn rn @Html.TextBox("PinNumber", item.PinNumber, new htmlAttributes = new @class = "form-control" );rn rn rn rn rn rn rn rn @Html.LabelFor(model => model.RowsCount, htmlAttributes: new @class = "control-label col-md-2" )rn rn rn @Html.EditorFor(model => model.RowsCount)rn @Html.ValidationMessageFor(model => model.RowsCount, "", new @class = "text-danger" )rn rn rn rn rn @Html.LabelFor(model => model.ColumnCount, htmlAttributes: new @class = "control-label col-md-2" )rn rn rn @Html.EditorFor(model => model.ColumnCount)rn @Html.ValidationMessageFor(model => model.ColumnCount, "", new @class = "text-danger" )rn rn rn rn rn rn @*// @Html.ActionLink("下一步", "List", Model)*@rn 论坛

没有更多推荐了,返回首页