【发布时间】:2014-02-01 04:40:36
【问题描述】:
我正在用 MVC 开发一个应用程序。
我有一个视图,其中绑定了两个部分视图。
我想做的是,我想将数据从一个局部视图传递到另一个局部视图。
在下面的示例中,产品列表部分视图给出了产品列表的总价格,我想将该总价格传递给税收部分视图以计算总价值的税金。
它应该在运行时完成。
如何做到这一点?
我的父视图
@model CRMEntities.Quotation
@{
}
<span class="ProductForm row-fluid">
@Html.Action("QuotationRelatedProductList", "Quotation", new { Id = @Model.Id })
</span>
Product Partial View
@model IEnumerable<CRMEntities.QuotationProduct>
<div id="divOpportunityProduct">
@if (Model != null)
{
i = 0;
foreach (var item in Model)
{
<input class="clsPrice" name='ProductPrice' type='text' id='txtPrice-@i' value="@EachProdPrice" style='font-size:12px;width:50px;margin-left:12px;' @*readonly="true"*@/>
<input name="Total" class="clsTotal" type='text' id='lblTotal-@i' style ='font-size:12px;width:50px;margin-left:14px;' @*readonly="true"*@/>
}
}
<div class="pull-left row-fluid" style="margin-top: 5px;">@Html.TextBox("txtGrandTotal", null, new {style="width:110px;"})</div>
<script type="text/javascript">
function GetGrandTotal() {
var AddTotal = 0;
var EachTotal;
$('input.clsTotal').each(function (index) {
var d = "lblTotal-" + index;
EachTotal = $('#' + d).val();
var y = new Number(EachTotal);
AddTotal = (AddTotal + y);
});
$("#txtGrandTotal").val(AddTotal);
}
</script>
现在,上面的总价值,我想在运行时传递给另一个视图....
【问题讨论】:
-
您最好花时间编写代码来描述您已经尝试过的内容,而不是制作图形。
-
好的,但是代码太庞大,放在这里...
-
请检查代码...
标签: asp.net-mvc model-view-controller