Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Popup Window Close issue

Status
Not open for further replies.

junkie8

Technical User
Aug 9, 2009
32
0
0
US
Hello All,

I wrote the following javascript code to open a pop up window in ff and ie.

function schedulerOpener(schedulerWindow) {
var browser = navigator.appName;
if (browser=="Microsoft Internet Explorer")
window.showModalDialog(schedulerWindow, 'window.self', 'center:yes;resizable:yes;status:no;dialogWidth:350px;dialogHeight:480px');
else
window.open(schedulerWindow, 'Schedule Event', 'width=350, height=480');
}


The window closes easily in ff, but when i try to close it on a button click in i.e, it opens another window. Can anyone help me. Also I want to reload the parent window before closing, this I am able to do in ff but not i.e.
(this javascript is in the code behind file of aspx page).
closeWindow function is called on a button click.

private void closeWindow()
{
string script = "<script type='text/javascript'>";
script += "window.close();";
script += "if (window.showModalDialog){";
script += "parent.location = parent.location;";
script += "window.returnValue = null;";
script += "window.close();}";
script += "else if ((window.opener != null) && (!window.opener.closed)){";
script += "window.opener.document.getElementById(ctr[1]).value = null;}";
script += "window.close();}";
script += "</script>";
Page.ClientScript.RegisterStartupScript(this.GetType(), "mykey1", script);
}
 
anyone has any idea how to solve this problem?
 
...try to close it on a button click...
I don't understand - you will have to be a lot more precise.

When you say button click... that implies there is a button to click (on the popup page). If there is, then the button must be in a form (otherwise your code will not validate - you do have validating code, right?).

So... when you click the button it probably attempts to submit the form. Where it sumbits to (when the window is closed) is indeterminate... and it may be opening a new page to deal with it.

Change the button to have something like this in the onlick:
Code:
<input type="button" value="Close" onclick="window.close();return false;"/>

Failing that... we'd probably have to see the client side (view source in the browser) of the popup window's button (that you expect to click to close the popup).

Hope that gets this rolling for you!
Jeff

[tt]Visit my blog [!]@[/!] Visit Code Couch [!]@[/!] [/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
I am posting the aspx code here. I have tried it already the above suggestion but still the same problem.

<html>
<head id="Head1" runat="server">
<title>Schedule Exam</title>
<style type="text/css">
.style2
{
width: 140px;
}
.style3
{
width: 142px;
}
.style7
{
width: 241px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<table style="border-left: thin groove olive; border-right-style: groove; border-right-width: thin; border-top-style: groove; border-top-width: thin; border-bottom-style: groove; border-bottom-width: thin;">
<tr>
<td colspan="3"
style="border: thin double #808000; font-weight:700; text-align: center; background-color: olive; color:White;">
<asp:Label ID="lblHeading" runat="server" Font-Names="Tahoma" Font-Size="Small"
Text="Schedule an Event"></asp:Label>
</td>
</tr>
<tr>
<td colspan="3">
&nbsp;</td>
</tr>
<tr>

<td align="center" colspan="3" >
<asp:Label ID="lblStartTime" runat="server" Font-Bold="False"
Font-Names="Tahoma" Font-Size="Small" Text="Start Time"></asp:Label> &nbsp;
<asp:TextBox ID="txtStartDate" runat="server" Width="80px" Font-Names="Tahoma"
Font-Size="Small" Height="19px"></asp:TextBox>
<asp:Image ID="imgCalendar1" runat="server" ImageUrl="~/Images/Calendar_scheduleHS.png" />
<cc1:CalendarExtender ID="clnExtender1" runat="server" TargetControlID="txtStartDate"
PopupButtonID="imgCalendar1"> </cc1:CalendarExtender> &nbsp;
<cc2:TimeSelector ID="tsStartTime" runat="server" AllowSecondEditing="False"
MinuteIncrement="10" Height="20px" Width="140px" />
</td>

</tr>
<tr>
<td colspan="3" style="text-align:center;">
<asp:Label ID="lblStartTimeError" runat="server" Font-Bold="True"
Font-Names="Tahoma" Font-Size="7pt" ForeColor="Red" Visible="False"></asp:Label>
</td>
</tr>
<tr>
<td align="center" colspan="3">&nbsp;
<asp:Label ID="lblEndTime" runat="server" Font-Bold="False" Font-Names="Tahoma"
Font-Size="Small" Text="End Time" ></asp:Label>&nbsp;
<asp:TextBox ID="txtEndDate" runat="server" Width="80px"
Font-Names="Tahoma" Font-Size="Small" Height="19px"></asp:TextBox>
<asp:Image ID="imgCalendar2" runat="server" ImageUrl="~/Images/Calendar_scheduleHS.png" />
<cc1:CalendarExtender ID="clnExtendar2" runat="server" TargetControlID="txtEndDate"
PopupButtonID="imgCalendar2"> </cc1:CalendarExtender> &nbsp;
<cc2:TimeSelector ID="tsEndTime" runat="server" AllowSecondEditing="false"
MinuteIncrement="10" Height="20px" Width="140px" />
</td>

</tr>
<tr>
<td colspan="3" style="text-align:center;">
<asp:Label ID="lblEndTimeError" runat="server" Font-Bold="True"
Font-Names="Tahoma" Font-Size="7pt" ForeColor="Red"
Text="End time must be greater than start time" Visible="False"></asp:Label>
</td>
</tr>
<tr>
<td align="center" colspan="3">
<asp:LinkButton ID="btnResources" runat="server" Font-Bold="True"
Font-Names="Tahoma" Font-Size="9pt" ForeColor="Olive"
onclick="btnResources_Click">Set Time</asp:LinkButton>
</td>
</tr>
<tr>
<td align="center" colspan="3">
&nbsp;</td>
</tr>
<tr>
<td align="center" colspan="3">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="lblEvent" runat="server" Font-Bold="False" Font-Names="Tahoma"
Font-Size="Small" Text="Event" Visible="false"></asp:Label>&nbsp;
<asp:DropDownList ID="ddlEvent" runat="server" Height="22px"
Font-Names="Tahoma" Font-Size="Small"
onselectedindexchanged="ddlEvent_SelectedIndexChanged"
AutoPostBack="True" Width="144px" Visible="false">
<asp:ListItem></asp:ListItem>
<asp:ListItem>Exam</asp:ListItem>
<asp:ListItem>Meeting</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td align="center" colspan="3">
&nbsp;
&nbsp;&nbsp;&nbsp;<asp:Label ID="lblProtocols" runat="server" Text="Protocol"
Visible="False" Font-Names="Tahoma" Font-Size="Small"></asp:Label>&nbsp;&nbsp;<asp:DropDownList
ID="ddlProtocols" runat="server" Height="22px"
Width="144px" Visible= "False" AutoPostBack="True"

onselectedindexchanged="ddlProtocols_SelectedIndexChanged"
Font-Names="Tahoma" Font-Size="Small">
</asp:DropDownList>
</td>
</tr>
<tr>
<td colspan="3" align="center">
<asp:UpdatePanel ID="selectionsPanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table>
<tr>
<td align="right">
<asp:Label ID="lblClinicID" runat="server" Font-Bold="False"
Font-Names="Tahoma" Font-Size="Small" Text="Clinic ID" visible="false"></asp:Label>
</td>
<td align="left" colspan="2">
<asp:TextBox ID="txtClinicID" runat="server" AutoPostBack="True"
CausesValidation="True" Font-Names="Tahoma" Font-Size="Small" Height="18px"
ontextchanged="txtClinicID_TextChanged" visible="false" Width="132px"></asp:TextBox>
<cc1:FilteredTextBoxExtender ID="txtClinicID_FilteredTextBoxExtender"
runat="server" Enabled="True" FilterType="Numbers"
TargetControlID="txtClinicID">
</cc1:FilteredTextBoxExtender>
&nbsp;<asp:RequiredFieldValidator ID="valClinicID" runat="server"
ControlToValidate="txtClinicID" Display="Dynamic" ErrorMessage="Required"
Font-Bold="True" Font-Names="Tahoma" Font-Size="7pt" SetFocusOnError="True"
Visible="False"></asp:RequiredFieldValidator>
<%--<cc1:ValidatorCalloutExtender ID="valClinicIDE"
runat="server" TargetControlID="valClinicID">
</cc1:ValidatorCalloutExtender>--%>
<asp:RangeValidator ID="rangeVldClinicID" runat="server"
ControlToValidate="txtClinicID" ErrorMessage="Invalid Number" Font-Bold="True"
Font-Names="Tahoma" Font-Size="Smaller" MaximumValue="999999999"
MinimumValue="0" Type="Double"></asp:RangeValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="lblRooms" runat="server" Font-Bold="False" Font-Names="Tahoma"
Font-Size="Small" Text="Room" visible="false"></asp:Label>
</td>
<td colspan="2" align="left">
<asp:DropDownList ID="ddlRooms" runat="server" DataTextField="room_name"
DataValueField="room_id" Font-Names="Tahoma" Font-Size="Small" Height="24px"
visible="false" Width="137px" AutoPostBack="True"
onselectedindexchanged="ddlRooms_SelectedIndexChanged"></asp:DropDownList>
&nbsp;<asp:Label ID="valRoom" runat="server"
Text="No room available" visible="False" Font-Bold="True"
Font-Names="Tahoma" Font-Size="7pt" ForeColor="Red"></asp:Label>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="lblEquipment" runat="server" Font-Bold="False"
Font-Names="Tahoma" Font-Size="Small" Text="Equipment" visible="false"></asp:Label>
</td>
<td colspan="2" align="left">
<asp:DropDownList ID="ddlEquipment" runat="server" DataTextField="equip_name"
DataValueField="equip_id" Font-Names="Tahoma" Font-Size="Small" Height="24px"
visible="false" Width="137px" AutoPostBack="True"
onselectedindexchanged="ddlEquipment_SelectedIndexChanged"> </asp:DropDownList>
&nbsp;<asp:Label ID="valEquip" runat="server"
Text="No equip available" visible="False" Font-Bold="True"
Font-Names="tahoma" Font-Size="7pt" ForeColor="Red"></asp:Label>
</td>
</tr>
<tr>
<td>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="lblAvailableWorkers" runat="server" Font-Bold="False"
Font-Names="Tahoma" Font-Size="Small" Text="Available Workers" visible="false"></asp:Label>
</td>
<td>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td>
<asp:Label ID="lblSelectedWorkers" runat="server" Font-Bold="False"
Font-Names="Tahoma" Font-Size="Small" Text="Selected Workers" visible="false"></asp:Label>
</td>
</tr>
<tr>
<td align="right" rowspan="2">
<asp:ListBox ID="lstAvailableWorkers" runat="server" visible="false" AutoPostBack="True"
DataTextField="name" Font-Names="Tahoma" Font-Size="Small" Height="70px"
Rows="100" Width="191px" DataValueField="pid">
<asp:ListItem></asp:ListItem>
</asp:ListBox>
</td>
<td>
<asp:Button ID="btnEmployeeRight" runat="server" visible="False"
onclick="btnEmployeeRight_Click" Text="--&gt;" Width="35px" OnClientClick="return true;" />

</td>
<td align="left" rowspan="2">
<asp:ListBox ID="lstSelectedWorkers" runat="server" AutoPostBack="True"
Font-Names="Tahoma" Font-Size="Small" Height="70px" Rows="100" visible="false"
Width="189px" DataTextField="name" DataValueField="pid"
style="margin-left: 0px"></asp:ListBox>
</td>
</tr>

<tr>
<td>
<asp:Button ID="btnEmployeeLeft" runat="server" onclick="btnEmployeeLeft_Click"
Text="&lt;--" Width="35px" visible="false"/>

</td>
</tr>
<tr>
<td colspan="3" style="text-align:center;">
<asp:Label ID="lblWorkers" runat="server" Font-Bold="True" Font-Names="Tahoma"
ForeColor="Red" font-size="7pt" Visible="False" ></asp:Label>
</td>
</tr>
<tr>
<td style="text-align:right;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="lblDescription" runat="server" Font-Names="Tahoma"
Font-Size="Small" Text="Event Description" Visible="False"></asp:Label>
</td>
<td colspan="2" style="text-align:left;">
<asp:TextBox ID="txtEventDescription" runat="server" Height="53px"
MaxLength="100" style="margin-left: 0px" TextMode="MultiLine" Visible="False"
Width="180px"></asp:TextBox>
<asp:RegularExpressionValidator ID="valDescription" runat="server"
ControlToValidate="txtEventDescription" Display="Dynamic"
ErrorMessage="Invalid Characters" Font-Bold="True" Font-Names="Tahoma"
Font-Size="7pt" SetFocusOnError="True"
ValidationExpression="[a-zA-z0-9\t\s,;:&amp;.'_-]*$" Visible="False"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>

<td colspan="3" style="text-align:center;">
<asp:Label ID="lblMessage" runat="server" Font-Bold="True" Font-Names="Tahoma"
ForeColor="Red" font-size="7pt" Visible="False" ></asp:Label>
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
<asp:postBackTrigger ControlID="btnEmployeeRight" />
<asp:postBackTrigger ControlID="txtClinicID" />
<asp:postBackTrigger ControlID="ddlRooms" />
<asp:postBackTrigger ControlID="ddlEquipment" />
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td align="center" class="style2">
&nbsp;</td>
<td align="center" class="style3">
&nbsp;</td>
<td align="center" class="style7">
&nbsp;</td>
</tr>
<tr>
<td align="center">
<asp:Button ID="btnCancel" runat="server" align="center" Text="Cancel" Width="78px"
Font-Bold="False" Font-Names="Tahoma" Font-Size="Small" Height="30px"
onclientclick="window.close();" onclick="btnCancel_Click" />
</td>
<td align="center">
<asp:Button ID="btnClear" runat="server" align="center" Text="Clear" Width="78px"
Font-Bold="False" Font-Names="Tahoma" Font-Size="Small" Height="30px"
onclick="btnClear_Click"
onclientclick="ValidatorEnable(valClinicID, false);"/>
</td>
<td align="center">
<asp:Button ID="btnSave" runat="server" align="center" Text="Save" Width="78px"
Font-Bold="False" Font-Names="Tahoma" Font-Size="Small" Height="30px"
onclick="btnSave_Click" Enabled="False" UseSubmitBehavior="true" />
</td>
</tr>
<tr>
<td colspan="3" align="center">
<asp:ObjectDataSource ID="objdsProtocols" runat="server"
OldValuesParameterFormatString="original_{0}" SelectMethod="GetExamProtocols"
TypeName="IUSO.AppCode.ExamProtocolsDSTableAdapters.ProtocolTableAdapter">
</asp:ObjectDataSource>
</td>
</tr>
</table>
</form>
</body></html>
 
sorry I meant to say that I have already tried setting onclick attribute to window.close() but I have had the same problem.
 
Well... if you can't follow simple directions:

me said:
...we'd probably have to see the client side (view source in the browser) of the popup window's button...

... then chances are we're not going to get very far with this. ASPX code is not the same as "client side". I have no interest in wading through all that junk... I am only interested in the rendered client-side source code. That's all that can help me (and most of the people here I imagine).

Have you tried using a link (and adding an onclick to that) instead of a button? Does that work for you? I bet it does.

Cheers,
Jeff

[tt]Visit my blog [!]@[/!] Visit Code Couch [!]@[/!] [/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Well I did not know what you meant by client side code when I had already posted closeWindow() which is written in code behind file in my first post. And I am clearly stating that this function is being called on button click.

What exactly do you want to see in client side?

Secondly, I have already tried link and I had the same problem.
 
ok, I guess I understand what you are saying. There is no way to view the source code of a Modal Window in internet explorer unless you know of one.
 
Surely there is no difference between the client-side source code of your popup page using Firefox and IE? You could view source using Firefox.

Cheers,
Jeff

[tt]Visit my blog [!]@[/!] Visit Code Couch [!]@[/!] [/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top