美好的一天。 我去过很多论坛,仍然无法掌握解决方案。系统具有此代码,其中用户单击文本框,然后单击新的" _blank"将出现包含表格。当用户单击该表中的select时,页面将关闭,所选用户的ID将传递给父页面。我怎样才能做到这一点?我尝试过在某些论坛中找到的某些脚本,但似乎无法正常工作。
这是我的子页面代码:
<table class="table table-hover">
<tr>
<th>@Html.DisplayNameFor(model => model.First().ID)</th>
<th>@Html.DisplayNameFor(model => model.First().Fullname)</th>
<th>@Html.DisplayNameFor(model => model.First().Address)</th>
</tr>
@foreach (var item in Model){
<tr>
<td>@Html.DisplayFor(modelItem => item.ID)</td>
<td>@Html.DisplayFor(modelItem => item.Fullname)</td>
<td>@Html.DisplayFor(modelItem => item.Address)</td>
<td>
<a href="@Url.Action("Close", new { ID = item.ID })" class="btn btn-warning" id="close" > Create <span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span>
</a>
</td>
</tr>
}</table>
@Html.PagedListPager(Model, page => Url.Action("Showw", new { page, searchString = Request.QueryString["searchString"] }), new PagedListRenderOptions() { Display = PagedListDisplayMode.IfNeeded })
@section Scripts{
<script type="text/javascript">
$("#close").click(function () {
var myWindow = window.open("", "_self");
myWindow.document.write("");
setTimeout(function () { myWindow.close(); }, 1000);
});
</script>
}
我有一个代码来检索id,但是一旦这个(子页面)关闭,它似乎无法找到适合将其传输到父页面的代码。再次感谢
答案 0 :(得分:0)
确实打开一个新的空白页面,你可以打开一个bootstrap模型
<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>
@Html.TextBox("displayVal","",new { id= "displayVal" })>
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<table border="1">
<tr data-dismiss="modal" class="val" data-val="001">
<td>001</td>
<td>One</td>
</tr>
<tr data-dismiss="modal" class="val" data-val="002">
<td>002</td>
<td>Two</td>
</tr>
<tr data-dismiss="modal" class="val" data-val="003">
<td>003</td>
<td>Three</td>
</tr>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(function () {
$(".val").click(function () {
$("#displayVal").val($(this).data("val"));
});
});
</script>
当用户点击表格行时,它会显示/将值传递给父页面