一、父窗口上:
<a href="#" onclick="OpenWin(this)" srclink="<%# "Employee_Update.aspx?E_id="+Eval("E_id") %>">
修改</a>对应的JS:
<script>
function OpenWin(obj)
{
var link=obj.srclink;
var height=parseInt(GetHeight()-30-250)/2;
var width=parseInt(GetWidth()-10-350)/2;
window.open(link,"","height=250, width=350, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no, left="+width+" , top="+height);
}
function GetHeight()
{
return window.screen.height;
} function GetWidth()
{
return window.screen.width;
}
</script>这样,当点击修改是,就会在父窗口上弹出子窗口“Employee_Update.aspx”。二、子窗口“Employee_Update.aspx”上<asp:Button ID="Btninfo" runat="server" OnClick="Btninfo_Click" OnClientClick="return EmpUpdate();" CssClass="buttoncss" Text="提交" /><script type="text/javascript" src="../../JS/MyJS.js">
function Close()
{
this.window.close();
}
</script>../../JS/MyJS.js里:function EmpUpdate()
{
var name=$('tbname');
if(IsNull(name))
{
return false;
}
else
return true;
}
function $(obj)
{
return document.getElementById(obj);
}
//判断输入内容是否为空
function IsNull(obj){
var str = obj.value.trim();
if(str.length==0){
alert('请填写完整信息!');
return true;//请将“文本框”改成你需要验证的属性名称!
}
else
return false;
}
但点击“提交”时,执行数据更新事件,然后子窗口自动关闭,并刷新了父窗口。问题一:开不明白,子窗口关闭是在哪里执行的???问题二:开不明白,父窗口为什么会自动刷新???
<a href="#" onclick="OpenWin(this)" srclink="<%# "Employee_Update.aspx?E_id="+Eval("E_id") %>">
修改</a>对应的JS:
<script>
function OpenWin(obj)
{
var link=obj.srclink;
var height=parseInt(GetHeight()-30-250)/2;
var width=parseInt(GetWidth()-10-350)/2;
window.open(link,"","height=250, width=350, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no, left="+width+" , top="+height);
}
function GetHeight()
{
return window.screen.height;
} function GetWidth()
{
return window.screen.width;
}
</script>这样,当点击修改是,就会在父窗口上弹出子窗口“Employee_Update.aspx”。二、子窗口“Employee_Update.aspx”上<asp:Button ID="Btninfo" runat="server" OnClick="Btninfo_Click" OnClientClick="return EmpUpdate();" CssClass="buttoncss" Text="提交" /><script type="text/javascript" src="../../JS/MyJS.js">
function Close()
{
this.window.close();
}
</script>../../JS/MyJS.js里:function EmpUpdate()
{
var name=$('tbname');
if(IsNull(name))
{
return false;
}
else
return true;
}
function $(obj)
{
return document.getElementById(obj);
}
//判断输入内容是否为空
function IsNull(obj){
var str = obj.value.trim();
if(str.length==0){
alert('请填写完整信息!');
return true;//请将“文本框”改成你需要验证的属性名称!
}
else
return false;
}
但点击“提交”时,执行数据更新事件,然后子窗口自动关闭,并刷新了父窗口。问题一:开不明白,子窗口关闭是在哪里执行的???问题二:开不明白,父窗口为什么会自动刷新???
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货