先上图:
其实里面的对话框是一个iframe,不把他们做到一个页面中主要方便模块式开发,而且可以带来禁用javascript的时候也能打开编辑界面的效果(当然关闭的时候还需要处理一下):
主要代码:把iframe显示为一个模拟对话框:
$("<iframe id='editFrame' src='EditPersonPage.aspx?action=insert' />").dialog({ autoOpen: true, modal: true, title: "新增人员" });
主界面:
<script type="text/javascript">
var insertClick = function(e) {
$("<iframe id='editFrame' src='EditPersonPage.aspx?action=insert' />").dialog({ autoOpen: true, modal: true, title: "新增人员" });
e.preventDefault();
};
var editClick = function(e) {
var editUrl = "EditPersonPage.aspx?action=edit&id=" + $(this).attr("rowid");
$("<iframe id='editFrame'/>").attr("src", editUrl).dialog({ autoOpen: true, modal: true, title: "编辑人员" });
e.preventDefault();
};
$(function() {
$("#linkInsert").click(insertClick);
$("a[action=edit]").click(editClick);
});
function CloseEditPage() {
$("#editFrame").dialog("close");
document.location.reload();
}
</script>
CloseEditPage方法是关闭对话框并且刷新,供编辑对话框调用。
编辑界面中在保存关闭以后调用父窗口的方法:window.parent.CloseEditPage()关闭编辑对话框。
protected void FormView1_ItemUpdated(object sender, FormViewUpdatedEventArgs e)
{
ClientScript.RegisterStartupScript(GetType(), "close", "window.parent.CloseEditPage();", true);
}
protected void FormView1_ItemInserted(object sender, FormViewInsertedEventArgs e)
{
ClientScript.RegisterStartupScript(GetType(), "close", "window.parent.CloseEditPage();", true);
}
这个程序在IE6、IE8、Firefox下都运行通过。
代码下载:http://files.cnblogs.com/rupeng/JQueryDlg.zip
如鹏网.Net培训班正在报名,有网络的地方就可以参加如鹏网的学习,学完就能高薪就业,点击此处了解
三年前只要懂“三层架构”就可以说“精通分层架构”;现在则需要懂IOC(AutoFac等)、CodeFirst、lambda、DTO等才值钱;
三年前只要会SQLServer就可以说自己“精通数据库开发”;现在则需还需要掌握MySQL等开源数据库才能说是“.Net开源”时代的程序员;
三年前只要会进行用户上传内容的安全性处理即可;现在则需要熟悉云存储、CDN等才能在云计算时代游刃有余;
三年前只要掌握Lucene.Net就会说自己“熟悉站内搜索引擎开发”;现在大家都用ElasticSearch了,你还用Lucene.Net就太老土了;
三年前发邮件还是用SmtpClient;现在做大型网站发邮件必须用云邮件引擎;
三年前缓存就是Context.Cache;现在则是Redis、Memcached的天下;
如鹏网再次引领.Net社区技术潮流!点击此处了解如鹏网.Net最新课程