I want to open a popup window and disable the parent window. Below is the code that I am using.For some reason, the parent window does not get disabled. I m using master page in my parent and adding onClientClick event to open pop up at page load of Parent page.Do I need some additional code OR what is the case?
<pre lang="Javascript">
<script type="text/javascript">
var popupWindow = null;
function OpenPopup() {
popupWindow = window.open("ClockPopUP.aspx", "Time", "scrollbars=no,resizable=no,width=550,height=350,left=300,top=300");
return false;
}
function parent_disable() {
if (popupWindow && !popupWindow.closed)
popupWindow.focus();
document.onmousedown = focusPopup;
document.onkeyup = focusPopup;
document.onmousemove = focusPopup;
}
function focusPopup() {
if (popupWindow && !popupWindow.closed) { popupWindow.focus(); }
}
function CheckDateEalier(sender, args)
{
var toDate = new Date();
toDate.setMinutes(0);
toDate.setSeconds(0);
toDate.setHours(0);
toDate.setMilliseconds(0);
if (sender._selectedDate < toDate)
{
alert("You can't select day earlier than today! In Case if you are selecting Previous date then, By default it will take current Date.");
sender._selectedDate = toDate;
sender._textbox.set_Value(sender._selectedDate.format(sender._format))
}
if (sender._selectedDate > toDate)
{
document.getElementById('<%= txtTimeSpent.ClientID%>').disabled = false;
}
}
</script>
Aspx Parent Page:
<asp:Content ID="Content1" ContentPlaceHolderID="cphTop" runat="server" >
<asp:ScriptManager ID="ScriptManger1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel runat="server" ID="updProduction">
<ContentTemplate>
<div id="counter" >
</div>
<div id="content">
<div id="right">
<asp:Button ID="Button1" runat="server" Text="Lunch" CausesValidation="false" CssClass="bigbuttons" style="background:url(../App_Themes/Images/green-box.gif)" Font-Bold="True" ForeColor="White" Font-Size="Large" /> <br />
<asp:Button ID="Button2" runat="server" Text="Break" CausesValidation="false" CssClass="bigbuttons" style="background:url(../App_Themes/Images/red-box.gif)" Font-Bold="True" ForeColor="White" Font-Size="Large" /> <br />
<asp:Button ID="Button3" runat="server" Text="L&D Training " CausesValidation="false" CssClass="bigbuttons" style="background:url(../App_Themes/Images/green-box.gif)" Font-Bold="True" ForeColor="White" Font-Size="Large" /> <br />
<asp:Button ID="Button4" runat="server" Text="Shift End" CausesValidation="false" CssClass="bigbuttons" style="background:url(../App_Themes/Images/red-box.gif)" Font-Bold="True" ForeColor="White" Font-Size="Large" /> <br />
</div>
<div id="formload" >
<fieldset>
<legend>Enter Date</legend>
<label for="input-one" class="float">Date</label><br />
<asp:TextBox ID="txtDate" runat="server" CssClass="inp-text" Enabled="False"
Width="300px"></asp:TextBox>
<asp:Image ID="btnDate2" runat="server" AlternateText="cal2"
ImageUrl="~/App_Themes/Images/icon_calendar.jpg" />
<ajaxToolkit:CalendarExtender ID="calExtender2" runat="server"
Format="dddd, MMMM dd, yyyy" OnClientDateSelectionChanged="CheckDateEalier"
PopupButtonID="btnDate2" TargetControlID="txtDate" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server"
ControlToValidate="txtDate" ErrorMessage="Select a Date" Font-Bold="True"
Font-Size="X-Small" ForeColor="Red"></asp:RequiredFieldValidator><br />
<br />
</fieldset>
<fieldset>
<legend>Production Detail</legend>
<label for="input-one" class ="float"> Time Spent In minutes</label><br />
<asp:TextBox ID="txtTimeSpent" runat="server" Width="300px" style="display:inherit;" CssClass="inp-text" Enabled="false"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="TimeSpent will be numeric and non decimal" ControlToValidate="txtTimeSpent" Font-Bold="True" Font-Size="X-Small" ForeColor="Red" ValidationExpression="^\d+$" Width="400px"></asp:RegularExpressionValidator>
<label for="input-one" class="float">Nature of Work </label><br />
<asp:DropDownList ID="ddlNatureofWork" runat="server" CssClass="inp-text"
Width="300px" onselectedindexchanged="ddlNatureofWork_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
<asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ErrorMessage="Please make a selection" ControlToValidate="ddlNatureofWork" InitialValue="--Select Nature of Work--" Font-Bold="True" Font-Size="X-Small" ForeColor="Red" ></asp:RequiredFieldValidator><br />
<label for="input-one" class="float">Region/Project Name </label><br />
<asp:DropDownList ID="ddlRegionProjectName" runat="server"
CssClass="inp-text" Width="300px"
onselectedindexchanged="ddlRegionProjectName_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
<asp:RequiredFieldValidator id="RequiredFieldValidator2" runat="server" Display="Dynamic" ErrorMessage="Please make a selection" ControlToValidate="ddlRegionProjectName" InitialValue="--Select Region/Project--" Font-Bold="True" Font-Size="X-Small" ForeColor="Red" ></asp:RequiredFieldValidator><br />
<label for="input-one" class="float">County Name</label><br />
<asp:DropDownList ID="ddlCountyName" runat="server" CssClass="inp-text"
Width="300px" AutoPostBack="true"
onselectedindexchanged="ddlCountyName_SelectedIndexChanged"></asp:DropDownList>
<asp:RequiredFieldValidator id="RequiredFieldValidator3" runat="server" ErrorMessage="Please make a selection" ControlToValidate="ddlCountyName" InitialValue="--Select County--" Font-Bold="True" Font-Size="X-Small" ForeColor="Red" ></asp:RequiredFieldValidator><br />
<label for="input-one" class="float">WorkType</label><br />
<asp:DropDownList ID="ddlWorkType" runat="server" CssClass="inp-text" Width="300px" AutoPostBack="true" onselectedindexchanged="ddlWorkType_SelectedIndexChanged"></asp:DropDownList>
<asp:RequiredFieldValidator id="RequiredFieldValidator4" runat="server" ErrorMessage="Please make a selection" ControlToValidate="ddlWorkType" InitialValue="--Select WorkType--" Font-Bold="True" Font-Size="X-Small" ForeColor="Red" ></asp:RequiredFieldValidator><br />
<label for="input-one" class="float">Task </label><br />
<asp:DropDownList ID="ddlTask" runat="server" CssClass="inp-text"
Width="300px" AutoPostBack="true"
onselectedindexchanged="ddlTask_SelectedIndexChanged"></asp:DropDownList>
<asp:RequiredFieldValidator id="RequiredFieldValidator5" runat="server" ErrorMessage="Please make a selection" ControlToValidate="ddlTask" InitialValue="--Select Task--" Font-Bold="True" Font-Size="X-Small" ForeColor="Red" ></asp:RequiredFieldValidator><br />
</fieldset>
<fieldset>
<legend>Completed Volumes</legend>
<label for="input-one" class="float">Volume Processed </label><br />
<asp:TextBox ID="txtVolumeProcessed" runat="server" CssClass="inp-text" Width="300px"></asp:TextBox>
<asp:RequiredFieldValidator id="RequiredFieldValidator6" runat="server" ErrorMessage="Please enter the volume processed" ControlToValidate="txtVolumeProcessed" Font-Bold="True" Font-Size="X-Small" ForeColor="Red" ></asp:RequiredFieldValidator><br />
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Volume must be numeric and non decimal" ControlToValidate="txtVolumeProcessed" Font-Bold="True" Font-Size="X-Small" ForeColor="Red" ValidationExpression="^\d+$" Width="400px"></asp:RegularExpressionValidator>
</fieldset>
<p><asp:ImageButton ID="ImgBtnSubmit" runat="server" ImageUrl="~/App_Themes/Images/form_submit.gif" onclick="ImgBtnSubmit_Click" /></p>
<p>
<asp:Label ID="lblConfirmation" runat="server" Text="Label" CssClass="labelError" Visible="false"></asp:Label> </p>
</div>
</div>
<div id="gridview">
<asp:GridView ID="GVUserEnteredDetails" runat="server" BackColor="White"
BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="15">
<FooterStyle BackColor="White" ForeColor="#000066" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
<RowStyle ForeColor="#000066" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#007DBB" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#00547E" />
</asp:GridView>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<div class="divTextAlign">
<asp:Updateprogress id="updProgress" runat="server" dynamiclayout="true" associatedupdatepanelid="updProduction">
<Progresstemplate>
<img src="App_Themes/Images/ajax-loader.gif" alt="" />
</Progresstemplate>
</asp:Updateprogress>
</div>
</asp:Content>