I want to pass values from a partialView (opened as a modal dialog) to the textbox in the parent view.
The PartialView
@model IEnumerable<Models.MembersList>
<div id="membersModal">
<h4>Members List</h4>
<table class="table table-responsive dataTable">
<thead>
<tr>
<th></th>
<th>Saving Ac No</th>
<th>Member Name</th>
<th>Saving Product</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td><a id="select" href="#" onclick="closeModal();">Select</a></td>
<td>@item.saving_account_no</td>
<td>@item.memberName</td>
<td>@item.product_name</td>
</tr>
}
</tbody>
</table>
</div>
<script type="text/javascript" src="~/Resource/js/jquery-ui.min.js"></script>
<script type="text/javascript">
function closeModal() {
$("#membersModal").hide();
}
$(".dataTable").DataTable();
</script>
The above partial view is called as the popup in the parent view.
@Html.TextBoxFor(x => x.memberName, new { @class = "form-control medium", @id = "memberName", style="width:80%" })
<div style="background-color: white; padding: 20px; margin: 0 auto" id="members"></div>
<script type="text/javascript">
var _dialog;
$('#memberName').focusin(function () {
_dialog = $("#members").dialog({
autoOpen: true,
position: { my: "center", at: "top+100", of: window },
width: 800,
resizable: false,
modal: true,
open: function () {
$(this).load('@Url.Action("_GetMemberList","MyController")');
},
close: function () {
closeModal("#members");
}
});
})
Now, when the partialView shows as a dialog, i need to select one of the value from the dialog close the modal [the modal is not closing] and display it in the "memberName" textBox.
Help needed ASAP.
Thank you.
What I have tried:
I don't know how to achieve this.