关闭第二页点击事件中第一页的modelpopup [英] Close modelpopup of first page in second page click event

查看:58
本文介绍了关闭第二页点击事件中第一页的modelpopup的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里,我有一种情况,就是使用javascript进行交叉浏览事件处理的情况.

1.我们在第一"屏幕上有一个模型弹出窗口,当单击模型弹出窗口中的按钮时,会打开一个新的屏幕第二".
2.屏幕"second"具有取消按钮,如果单击取消",则必须关闭"second"屏幕以及第一个屏幕modelpopup.

我们正在使用window.close()关闭第二个"屏幕,同时,我们必须找到第一个窗口modelpopup并将其关闭.

Here I have one scenario, something cross browsing event handling in javascript.

1. We have a modelpopup on a screen ''first'', when click a button which is in modelpopup, opening a new screen ''second''.
2. Screen ''second'' has a button cancel, if click on cancel I have to close the ''second'' screen, as well the first screen modelpopup.

We are using window.close() to close the ''second'' screen, at the same time, we have to find the first window modelpopup and close it.

Can some one please provide the script.

推荐答案



假设您的modelpopup的ID在page1中为mpopup.

在按钮页面2的onclick上编写以下javascript代码

window.opener.document.getElementbyID(''<%= mpopup.clientID%>'').hide();//关闭模型弹出
window.close();//要关闭第二个窗口
Hi,

Assuming your modelpopup with id as mpopup in page1.

Write the following javascript code onclick of button page 2

window.opener.document.getElementbyID(''<%=mpopup.clientID%>'').hide();//To close the modelpopup
window.close();//to close second window


在第一页中,我们在div中单击了取消"按钮,该按钮的显示应该为空,而我们必须使用"CancelControlID ="btnCancel"属性如下

< asp:HiddenField ID ="hidWifiLocation" runat ="server"/>
< div class ="popup_Buttons" style ="display:none">
< input id ="btnCancel" type ="button" value ="Cancel"/>
</div>
< cc1:ModalPopupExtender ID ="mpeWifiLocation" runat ="server" TargetControlID ="hidWifiLocation"
PopupControlID ="pnlWifiLocation" CancelControlID ="btnCancel" BackgroundCssClass ="modalbackground">
</cc1:ModalPopupExtender>

并且在第二页中必须使用取消"按钮,该按钮应该是可见的,并且需要在onclientclick时调用js函数,请参见下面的代码

< asp:Button ID ="btnCancel" runat ="server" TabIndex ="12" Text ="Cancel" AccessKey ="C"
CausesValidation ="false" OnClientClick ="cancel();" CssClass ="btn"/>

< script type ="text/javascript">
函数cancel()
{
window.parent.document.getElementById(''btnCancel'').click();
}
</script>
In First page we have take the cancel button in div which display should be none and we have to take the CancelControlID="btnCancel" property as below

<asp:HiddenField ID="hidWifiLocation" runat="server" />
<div class="popup_Buttons" style="display: none">
<input id="btnCancel" type="button" value="Cancel" />
</div>
<cc1:ModalPopupExtender ID="mpeWifiLocation" runat="server" TargetControlID="hidWifiLocation"
PopupControlID="pnlWifiLocation" CancelControlID="btnCancel" BackgroundCssClass="modalbackground">
</cc1:ModalPopupExtender>

and in Second page will have to take the cancel button which should be visible and need to call the js function while onclientclick see below code

<asp:Button ID="btnCancel" runat="server" TabIndex="12" Text="Cancel" AccessKey="C"
CausesValidation="false" OnClientClick="cancel();" CssClass="btn" />

<script type="text/javascript">
function cancel()
{
window.parent.document.getElementById(''btnCancel'').click();
}
</script>


这篇关于关闭第二页点击事件中第一页的modelpopup的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆