.NET同一个页面父容器与子容器通信方案
主界面:


关键主页面代码:
<div id="EditDiv">
<iframe src="javascript:void(0)" id="editFrame" width="100%" height="100%" frameborder="0"></iframe>
</div> ---------------以下js脚本(关键代码)-----------
//绑定修改的超链接
function bindEditLinkClickEvent() {
$(".editLink").click(function () {
var newsId = $(this).attr("newsId");
//getNews2EditForm(newsId); //从后台加载数据然后把数据放到修改文本框上去
//弹出对话框之前,把iframe标签的src属性设置成修改页面地址
$("#editFrame").attr("src", "EditNews.aspx?id="+newsId);
showEditDialog(); //弹出编辑div
});
}; //弹出编辑div
function showEditDialog() {
$("#EditDiv").css("display", "block");
$("#EditDiv").dialog({
title: "修改对话框",
width: 500,
height: 500,
modal: true,
collapsible: true,
minimizable: true,
maximizable: true,
resizable: true,
buttons: [{
text: "修改",
iconCls: "icon-add",
handler: submitChildEditFrm
}, {
text: "关闭",
iconCls: "icon-cancel",
handler: function () {
$("#EditDiv").dialog("close");
}
}]
});
} //异步提交子页面的表单
function submitChildEditFrm() {
//先拿到子容器的windows对象,并调用子容器的js函数
var domFrame = $("#editFrame")[0];
domFrame.contentWindow.submitFrm();
};
子容器代码:
<form id="form1" runat="server">
<div>
<input type="hidden" name="id" value="<%=News.id %>" id="id" />
<table>
<tr>
<td>新闻标题</td>
<td><input type="text" name="title" id="txtTitle" value="<%=News.title %>" /></td>
</tr>
<tr>
<td>新闻内容</td>
<td><input type="text" name="contents" id="txtContent" value="<%=News.contents %>" /></td>
</tr>
</table>
</div>
</form> //-----以下JS脚本-------
<script src="../Script/jquery-3.4.1.js"></script>
<script type="text/javascript">
function submitFrm() {
//让表单整体异步的提交后台。
var postData = $("#form1").serializeArray();
$.ajax({
url: "EditNews.aspx",
type: "post",
dataType: "json",
data: postData,
success: function (data) {
if (data.success == "ok") {
alert("修改成功!");
//关闭父容器的对话框,刷新父容器的表格
window.parent.window.afterEditSuccess();
} else {
alert("修改失败!")
}
},
error: function (err)
{
alert(err);
}
});
}
</script>
搞定~~
.NET同一个页面父容器与子容器通信方案的更多相关文章
- 父容器根据子容器高度自适应:设置父容器 height:100%;overflow:hidden;
父容器根据子容器高度自适应:设置父容器 height:100%;overflow:hidden;
- 查看Spring MVC 父容器和子容器的对象的实例
话不多说,直接上案例 package com.oukele.web; import org.springframework.beans.factory.annotation.Autowired; im ...
- 结合源码浅谈Spring容器与其子容器Spring MVC 冲突问题
容器是整个Spring 框架的核心思想,用来管理Bean的整个生命周期. 一个项目中引入Spring和SpringMVC这两个框架,Spring是父容器,SpringMVC是其子容器,子容器可以看见父 ...
- Spring MVC 根容器和子容器
整合 spring mvc 根容器和子容器 public class TestWebInitializer extends AbstractAnnotationConfigDispatcherServ ...
- Spring父容器与子容器
在使用spring+springMVC的web工程中,我们一般会在web.xml中做如下配置: <context-param> <param-name>contextConfi ...
- Spring - 父容器与子容器
一.Spring容器(父容器) 1.Mapper代理对象 2.Service对象 二.Springmvc(前端控制器)(子容器) Controller对象 1.标准的配置是这样的:Con ...
- 【CSS】div父容器根据子容器大小自适应
Div即父容器不根据内容自动调节高度,我们看下面的代码: <div id="main"> <div id="content"></ ...
- html 父容器和子容器通信
通过拿到document对象下的window对象后执行对应的方法.
- SpringMVC——DispatcherServlet的IoC容器(Web应用的IoC容器的子容器)创建过程
在上一篇<Spring--Web应用中的IoC容器创建(WebApplicationContext根应用上下文的创建过程)>中说到了Web应用中的IoC容器创建过程.这一篇主要讲Sprin ...
随机推荐
- WebService发布服务例子
import javax.jws.WebMethod; import javax.jws.WebService; @WebService public interface WebServiceI { ...
- vue浏览器全屏实现
1.项目中使用的是sreenfull插件,执行命令安装 npm install --save screenfull 2.安装好后,引入项目,用一个按钮进行控制即可,按钮方法如下: toggleFull ...
- 更改docker默认网段
#本文档旨在说明创建docker时注意的事项:我们在局域网中使用Docker,最常遇到的一个困惑,就是有时候跨网段结果出现网络不通.原因是因为Docker默认生成的网关和我们的局域网网段有时候是冲突的 ...
- SRDC - ORA-1562: Checklist of Evidence to Supply (Doc ID 1682728.1)
SRDC - ORA-1562: Checklist of Evidence to Supply (Doc ID 1682728.1) Action Plan 1. Execute srdc_db_ ...
- .net core 发布IIS 出现Http 500错误
首先再webconfig中设置stdoutLogEnabled="true",然后运行之后,到logs中查看登陆错误日志. 根据不同的错误进行解决: 我的错误是发布文件夹中缺少Dw ...
- PLSQL Developer数据库连接和tnsname.ora的配置
1.将资源解压,打开解压完成目录中的PLSQL Developer文件夹,双击plsqldev.exe图标打开PLSQL Developer. 打开help>>about中找到TNS Fi ...
- Matplotlib Date Index Formatter 日期索引格式化学习
官方网站:https://matplotlib.org/gallery/ticks_and_spines/date_index_formatter2.html#sphx-glr-gallery-tic ...
- 分析-flag被盗
用wireshark打开数据包 寻找http协议的数据 找一个post包进行TCP追踪流 寻找flag
- windows server2008 R2下mysql 5.7版本中修改编码为utf-8的方法步骤
首先通过 show variables like 'character_set_%'; 查看mysql字符集情 默认编码为 latin1 然后关闭数据库 在mysql安装目录下找到my.ini文件 在 ...
- day55_9_19模型层的操作
一.配置settings. 如果是queryset对象 那么可以点query直接查看该queryset的内部sql语句 将以下代码放入settings中.就可以实现当使用orm时查看sql语句: LO ...