I have implemented javascript code on my main page that triggers a popup when a link is clicked:
<script language="javascript">
function OpenResidentialAddressWin(subscriberContactRelationGid, routeId, btn) {
window.showModalDialog("SubscriberResidentialAddress.aspx" + BuildQueryStringValuesForSubscriber(subscriberContactRelationGid, routeId, returntxtReceiptDate().value), this, strWindowFeatures + ";scroll:no;dialogWidth:442px;dialogHeight:350px");
location.href = location.href;
}
</script>
The above script opens the page SubscriberResidentialAddress.aspx in a modal window with various variables passed into it.
This page has sections for displaying and editing information, which are toggled based on button interactions within the window.
Currently, after saving information, the page switches to display mode. Instead, I aim to close the modal window completely and refresh the main page.
A colleague recommended using a literal control on the aspx page of the modal window and executing JavaScript post successful save. In the head section of SubscriberResidentialAddress.aspx, I added:
<asp:Literal runat="server" ID="litCloseWind"></asp:Literal>
In the code-behind, within the function triggered upon save:
protected void btnAddSave_Click(object sender, EventArgs e)
{
////// saving-related code
if (status.IsSuccessful)
{
litCloseWind.Text = "<script>this.close()</script>";
Response.Redirect(Request.Url.AbsoluteUri, false);
}
}
I tried the above approach, including 'litCloseWind.Text = "window.close()";', but none successfully closed the modal window after a save operation.
Is this strategy logically correct, or did I make an error somewhere? Or perhaps, was this not the best method to begin with?