MVC弹出子页面向父页面传值
2015-07-30 14:18
417 查看
实现思路是使用js在父子页面间传值
视图一代码,父页面
视图二代码:子页面
视图一代码,父页面
@{ ViewBag.Title = "Index"; } <script type="text/javascript"> //alert("1"); function test() { window.showModalDialog('test/listtest', 'newwindow', 'height=400,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=yes,location=no, status=no') var temp = window.showModalDialog('test/listtest', 'newwindow', 'height=400,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=yes,location=no, status=no') document.getElementById("test").value = temp; } </script> <h2>@ViewData["Message"]</h2> <p><input type="submit" value="submit" onclick="test()"></p> <p><input type="text" id="test"></p>
视图二代码:子页面
@model IEnumerable<mvctest.Models.student> @{ ViewBag.Title = "listtest"; } <script type="text/javascript"> function sendvalue(a) { alert(a); document.getElementById("test").value = a; window.returnValue = a; window.close(); } </script> <p> <input type="submit" value="sendvalue" onclick="sendvalue()"> <input type="text" id="test" value=sendvalue> </p> <h2>listtest</h2> <p> @Html.ActionLink("Create New", "Create") </p> <table id="table1"> <tr> <th> @Html.DisplayNameFor(model => model.name) </th> <th> @Html.DisplayNameFor(model => model.password) </th> <th> @Html.DisplayNameFor(model => model.descript) </th> <th></th> </tr> @foreach (var item in Model) { <tr> <td> @Html.DisplayFor(modelItem => item.name) </td> <td> @Html.DisplayFor(modelItem => item.password) </td> <td> @Html.DisplayFor(modelItem => item.descript) </td> <td> <input type="button" value="haha" onclick="sendvalue('@item.name')"> </td> </tr> } </table>
相关文章推荐
- 一个简单的多背景时间显示网页
- $injector
- Go-数据库连接
- AbstractProcessor一些用法
- HDU 1021 Fibonacci Again
- 依存句法CoNLL-U 格式(CoNLL2014)
- Pinot安装并简单部署测试环境
- ios下 active 演示激活
- Android开发学习笔记:WebView 一
- Android procrank , showmap 内存分析
- RHEL十七(计划将来的Linux任务)
- mac 安装homebrew
- 结合"hello world"探讨gcc编译程序的过程
- hdu 4324 Triangle LOVE 拓扑排序
- Xcode6及以上版本,创建Auto Layout 约束时产生的一些变化
- 实用CMD命令
- 开发运行hadoop的AvgScore程序
- 输入年月日时分秒,要求输出该年月日时分秒的下一秒,如果输出2004年12月31日59分59秒,输出2005年1月1日0时0分0秒
- 时屏蔽ios和android下点击元素时出现的阴影
- hdu 4324 Triangle LOVE 拓扑排序