Добрый день.
У меня есть вид 3 панели.В каждой панели есть несколько EditorFor, одна из которых редактируемая, а остальные только для чтения.Когда пользователь нажимает на редактируемый EditorFor, появляется модальное окно с таблицей клиентов.После нажатия кнопки «Выбрать» окно EditorFor на панели будет заполнено на основе значения из таблицы.
Проблема заключается в том, что у меня есть эти 2 панели, для каждой из которых назначены разные модальные функции.Если я выбрал значение из первой таблицы из первого режима, первая панель будет заполнена, но когда я выбрал значение из второй таблицы из второго режима, данные первой панели будут утеряны, и только вторая панель будет иметь значение.
Вот пример
Контроллер
public ActionResult DroppingApplication(string Petname, string Petaddress, string Objid, string Opid, string Opname, string Mno, string Franid)
{
ViewBag.DrpReason = new SelectList(db.tbl_DroppingReason, "id", "Reason");
ViewBag.Petname = Petname;
ViewBag.Petaddress = Petaddress;
ViewBag.Petid = Objid;
ViewBag.Opname = Opname;
ViewBag.Opid = Opid;
ViewBag.Fno = Franid;
ViewBag.Mno = Mno;
return View();
}
DroppingApplication View
@model iVehicles.ViewModel.DropViewModel
<div>
@using (Html.BeginForm("Index", "Application", FormMethod.Post, new { @id = "submitFormFirst" }))
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<br />
<br />
<div class="col-md-6 col-md-offset-3">
@* ----------------------------------------------------------------
PETITIONER
----------------------------------------------------------------
*@
<div class="panel panel-primary col-md-6 col-md-offset-3">
<div class="panel-heading"><h4>PETITIONER INFORMATION</h4></div>
<div class="panel-body">
<div class="form-group">
@Html.EditorFor(model => model.petitioner_id, new { htmlAttributes = new { @class = "form-control hidden", @readonly = "readonly", @id = "objid", @Value = ViewBag.Objid } })
</div>
<div class="form-group">
@Html.LabelFor(model => model.petitioner_name, htmlAttributes: new { @class = "control-label" })
@Html.EditorFor(model => model.petitioner_name, new { htmlAttributes = new { @class = "form-control", placeholder = @Html.DisplayNameFor(m => m.petitioner_name), @id = "petname" , @Value = ViewBag.Petname, data_toggle = "modal", data_target = "#myModal", data_backdrop = "static", data_keyboard = "false" } })
@Html.ValidationMessageFor(model => model.petitioner_name, "", new { @class = "text-danger" })
</div>
<div class="form-group">
@Html.LabelFor(model => model.petitioner_address, htmlAttributes: new { @class = "control-label" })
@Html.EditorFor(model => model.petitioner_address, new { htmlAttributes = new { @class = "form-control", @readonly = "readonly", placeholder = @Html.DisplayNameFor(m => m.petitioner_address), @id = "petaddress", @Value = ViewBag.Petaddress } })
@Html.ValidationMessageFor(model => model.petitioner_address, "", new { @class = "text-danger" })
</div>
</div>
</div>
@* ----------------------------------------------------------------
PETITIONEE
----------------------------------------------------------------
*@
<div class="panel panel-primary col-md-6 col-md-offset-3">
<div class="panel-heading"><h4>PETITIONEE INFORMATION</h4></div>
<div class="panel-body">
<div class="form-group">
@Html.EditorFor(model => model.operator_id, new { htmlAttributes = new { @class = "form-control hidden", @readonly = "readonly", @id = "opid", @Value = ViewBag.Opid } })
</div>
<div class="form-group">
@Html.EditorFor(model => model.franchise_id, new { htmlAttributes = new { @class = "form-control hidden", @readonly = "readonly", @id = "franid", @Value = ViewBag.Fno } })
</div>
<div class="form-group">
@Html.LabelFor(model => model.operator_name, htmlAttributes: new { @class = "control-label" })
@Html.EditorFor(model => model.operator_name, new { htmlAttributes = new { @class = "form-control", placeholder = @Html.DisplayNameFor(m => m.operator_name), @id = "opname", @Value = ViewBag.Opname, data_toggle = "modal", data_target = "#myModal2", data_backdrop = "static", data_keyboard = "false" } })
@Html.ValidationMessageFor(model => model.operator_name, "", new { @class = "text-danger" })
</div>
<div class="form-group">
@Html.LabelFor(model => model.motor_no, htmlAttributes: new { @class = "control-label" })
@Html.EditorFor(model => model.motor_no, new { htmlAttributes = new { @class = "form-control", @readonly = "readonly", placeholder = @Html.DisplayNameFor(m => m.motor_no), @id = "mno", @Value = ViewBag.Mno } })
@Html.ValidationMessageFor(model => model.motor_no, "", new { @class = "text-danger" })
</div>
</div>
</div>
<div class="col-md-6 col-md-offset-3">
<input type="submit" value="Next" id="submitBtn" class="btn btn-success" />
</div>
</div>
</div>
}
</div>
@*--------------------------------------MODAL 1------------------------------------------------*@
<div class="modal fade" id="myModal" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content ">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
@{Html.RenderAction("PayerList", "Dropped");}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
@*--------------------------------------MODAL 2------------------------------------------------*@
<div class="modal fade" id="myModal2" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content ">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
@{Html.RenderAction("OperatorList", "Dropped");}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
Частичное представление PayerList
<td>
<a href="@Url.Action("DroppingApplication","Dropped",new { Objid= @item.objid, Petname=@item.name, Petaddress=@item.primaryaddress })"class="button" onclick="SetName();">Select</a>
</td>
@section Scripts{
<script type="text/javascript">
function SetName() {
var txtName = window.opener.document.getElementById("petname");
var txtAddress = window.opener.document.getElementById("petaddress");
var txtObjid = window.opener.document.getElementById("objid");
txtName.value = document.getElementById('Petname').value;
txtAddress.value = document.getElementById('Petaddress').value;
txtObjid.value = document.getElementById('Objid').value;
}
</script>
}
Частичное представление OperatorList
<td>
<a href="@Url.Action("DroppingApplication","Dropped",new { Opid= @item.operator_id, Opname= @item.operator_id, Franid=@item.franchise_id, Mno=@item.motor_no })" class="button" onclick="SetName();">Select</a>
</td>
@section Scripts{
<script type="text/javascript">
function SetName() {
var txtOpname = window.opener.document.getElementById("opname");
var txtOpid = window.opener.document.getElementById("opid");
var txtMno = window.opener.document.getElementById("mno");
var txtFranid = window.opener.document.getElementById("franid");
txtOpname.value = document.getElementById('Opname').value;
txtOpid.value = document.getElementById('Opid').value;
txtMno.value = document.getElementById('Mno').value;
txtFranid.value = document.getElementById('Franid').value;
}
</script>
}
Заранее спасибо.