将数据从局部视图传递到父视图 [英] Passing data from partial view to parent view
问题描述
我想将partialView(作为模式对话框打开)中的值传递到父视图中的文本框。
PartialView
@ model IEnumerable < Models.MembersList >
< div id = membersModal >
< h4 > 成员列表< / h4 >
< table class = table table-responsive dataTable >
< thead >
< tr >
< th > < / th >
< th > 保存Ac否< / th >
< th > 会员名称< / th >
< th < span class =code-keyword>> 保存产品< / th < span class =code-keyword>>
< / tr >
< / thead >
< tbody >
@foreach(模型中的var项目)
{
< tr >
< td > < a id = 选择 href = # onclick = closeModal(); > 选择< / a > < / td >
< td > @ item.saving_account_no < / td >
< td > @ item.memberName < / td < span class =code-keyword>>
< td > @ item.product_name < / td >
< / tr >
}
< / tbody >
< / table < span class =code-keyword>>
< / div >
< script type = text / javascript src = 〜/ Resource / js / jquery-ui.min.js > < / sc ript >
< script type = text / javascript >
function closeModal(){
$( #membersModal)。hide( );
}
$( 。dataTable)。DataTable ();
< / script >
以上部分视图称为弹出窗口父视图。
@ 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 },
宽度: 800 ,
可调整大小: false ,
modal: true ,
open: function (){
$( this )。load(' @ Url.Action(_ GetMemberList,MyControl LER)'跨度>);
},
关闭: function (){
closeModal( #members);
}
});
})
现在,当partialView显示为对话框时,我需要从对话框中选择一个值关闭模态[模态未关闭]并将其显示在memberName文本框中。
尽快帮助。
谢谢。
我试过的:
我不知道怎么做到这一点。
< blockquote>( #membersModal)。hide();
}
( 。dataTable) .DataTable();
< / script >
以上部分视图称为弹出窗口父视图。
@ 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 =
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.
("#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 =
这篇关于将数据从局部视图传递到父视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!