Click here to Skip to main content
15,908,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

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
 
Share this answer
 
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>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900