方法一:
EPOBS.aspx页面:
function Add()
{
result=window.showModalDialog("ModalDialogFrame.aspx?Title=选择组织部门&PageUrl=ParentTreeView.aspx",window,"dialogWidth=380px;dialogHeight=650px;status=no;center=yes;");
if(result="OK")
window.location.href=window.location.href;
}
ModalDialogFrame.aspx页面:
<%@ Page language="c#" Codebehind="ModalDialogFrame.aspx.cs" AutoEventWireup="false" Inherits="LinkProject.BaseInfo.EPOBS.ModalDialogFrame" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>ModelDialogFrame</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
function GetQueryString(key)
{
var re = new RegExp("[&,?]"+key + "=([^//&]*)", "i");
var a = re.exec(document.location.search);
if (a == null)
return "";
return a[1];
}
function Return(RtValue)
{
window.returnValue=RtValue;
window.close();
}
function DataInitial()
{
var PageUrl=GetQueryString('PageUrl');
var Title=GetQueryString("Title");
if(Title!="")
document.title=Title;
PageUrl=PageUrl.replace(//|/g,"&");
Frame1.document.location=PageUrl;
}
</script>
</head>
<body MS_POSITIONING="GridLayout" οnlοad="DataInitial();">
<iframe id="Frame1" src="" width="100%" height="100%" frameborder="no"></iframe>
</body>
</html>
ParentTreeView.aspx页面:
后台代码:
public void AddNodes()
{
DEP_Project dep = null;
DepChild dc=new DepChild();
string[] list = this.hdFID.Value.Split(',');
string UserName=this.TheSession["UsrName"].ToString();
try
{
for(int i=0;i<list.Length;i++)
{
dep=dc.getDEP_Project(list[i]);
if(dep == null)
{
dep = new DEP_Project();
setDEP_Project(dep,Convert.ToInt32(list[i]),UserName);
dc.AddNodes(dep);
}
}
this.Page.RegisterStartupScript("msg","<script language=javascript>parent.Return('OK');</script>");
}
catch(Exception ex)
{
}
}
方法二:
ChangeList.aspx页面:
前台JS:
function Add()
{
Form1.hdOper.value="add";
window.showModalDialog("ChangeAdd.aspx?info=add&code="+Form1.hdcode.value+"&ChangeType="+Form1.hdChangeType.value,window,"dialogwidth=550px;dialogheight=350px;status=no;center=yes");
}
function Reload()
{
if(Form1.hdOper.value=="add")
window.location.href="ChangeList.aspx?listCode="+Form1.hdcode.value+"&index="+document.getElementById("Pager1_list").value+"&ChangeType="+Form1.hdChangeType.value+"&prjid="+Form1.hdprj.value;
else if(Form1.hdOper.value=="edit")
window.location.href="ChangeList.aspx?listCode="+Form1.hdcode.value+"&id="+Form1.hdItemChangeID.value+"&index="+document.getElementById("Pager1_list").value+"&ChangeType="+Form1.hdChangeType.value+"&prjid="+Form1.hdprj.value;
}
ChangeAdd.aspx页面:
前台:
<base target="_self">
后台:
private void SaveData()
{
PT_ItemChange ic=null;
fic=new FItemChange();
if(this.hdinfo.Value=="add"&&this.hdFID.Value=="0")
{
ic = new PT_ItemChange();
this.setEntity(ic);
ic.State=0; //未审批
fic.Add_ItemChange(ic);
this.hdFID.Value="0";
Page.RegisterStartupScript("ms","<script type='text/javascript' language='javascript'>alert('添加成功!');window.close();window.dialogArguments.Reload();</script>");
}
else if(this.hdinfo.Value=="edit"&&this.hdFID.Value!="")
{
ic=fic.Get_ItemChange(hdFID.Value);
this.setEntity(ic);
fic.Update_ItemChange(ic);
this.hdFID.Value="";
Page.RegisterStartupScript("msg","<script type='text/javascript' language='javascript'>alert('修改成功!');window.close();window.dialogArguments.Reload();</script>");
}
}
在父页面中定义,在子页面中实现父页面中定义的属性或方法,在父页面获取子页面返回的值