window.showModalDialog problem
I have button on Search.aspx page. when user clicks on that button a new window appears
using following javascriptfunction GotoSelectProgram(memberid)
{
var url2 = "SelectProgram.aspx?MID="+memberid;
str = window.showModalDialog(url2);
}the above script will create new window for SelectProgram.aspx page. This new page has
datagrid with few rows. and each row has ImageButton called Select. when user select any row
i want to close that popup window and parent window should navigate to ProgramUpdate.aspxim using following c# code in click event of select button
private void MemberDetails1_SelectorChanged(object sender, ProgramEventArgs e)
{
// some code hereResponse.Write("<script language='javascript'>window.close();window.opener.location.href = 'ProgramUpdate.aspx'</script>");
}the above code works fine if i use window.open instead of window.showModalDialog.
but if i use window.showModalDialog, when user clicks on select, control goes to ProgramUpdate.aspx page as i wanted but
parent window still shows Search.aspx and Popup window is still there, it wont get closed.
Answers
add this line to the child window page html...
<base target="_self">
All Replies
i'll put above question in simple way
i have Main.aspx page with one button.
On click event it will execute following javascript codefunction ShowDialog()
{
window.showModalDialog("Child.aspx");
}
on child.aspx i have one more button
on click event it will execute following javascript codefunction CloseDialog()
{
window.close();
}why its not closing Child window and control is also not going back to main window.
- Hey lax4u
Try this,var childWindow;
function ShowDialog()
{
childWindow = window.showModalDialog("Child.aspx");
}function CloseDialog()
Hope this helps.
{
childWindow.close();
} In fact, the problem is:
In the new window, click any button will generate a new window.
If you don't use "close" in the script, you'll find another window shows up.
I'm seeking the solution of this. Any advice is appreciated!
add this line to the child window page html...
<base target="_self">
kjames wrote: add this line to the child window page html...
<base target="_self">
KJames
Can you elaborate this further!
Hi
Even i am facing the same issue.
I even tried <base target="_self">
Then also i am facing the issue.
Any pointer will be of great help.
use this,
"window.dialogArguments.location.href = ''
and then window.close
hope it helps
sahridhayan
use <base target="_self" /> under head section
Hi
thank u.u helped me so much.
Thanks Kjames. That worked. I had to add the <base target="_self" /> in the head section.
I was struggling with this for the past 4 hrs!!
- thanks a lot, it really worked by placing <base target="_self"> in the head section.
thanks once again.
ShadowMan : The Lord of Dead Side Is it ok? <base ...>?
Thanks every body....
I was also worring for the same.
anyway it helped me a lot.- Hi.I use a Master Page where I Put this code:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="MasterPager.Master.cs" Inherits="BillerManager.Web.UI.Portal.MasterPager" %> <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Biller Manager</title> <asp:ContentPlaceHolder ID="head" runat="server"> </asp:ContentPlaceHolder> <base target="_self" /> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <ext:ScriptManager ID="ScriptManager2" runat="server" Theme="Gray"> </ext:ScriptManager> <table style="height: 100%; width: 97%; border-color: Gray;" border="2" align="center" cellpadding="0" cellspacing="0"> <asp:Panel runat="server" ID="pnlToolbar"> . . . . <asp:SiteMapDataSource ID="msdsMenu" runat="server" ShowStartingNode="False" /> </form> </body> </html>
in a ParentPage.aspx I've a GridView where I create runtime a link to open new asp with popup modal:protected void gvDiagnostics_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { LinkButton hyp = (LinkButton)(e.Row.Cells[0].FindControl("link")); hyp.Text = "Details"; string url = Request.Url.ToString(); string modalPopup = String.Format("window.showModalDialog('{0}?id={1}&viewTB=false','','dialogwidth: 450; dialogheight: 300; resizable: yes;');document.location.reload(true)", url, idObject.Text); hyp.Attributes["OnClick"] = "javascript:" + modalPopup; } }
and in the child.aspx page, there is the follow code, linked a close buttonThis code run correctly (parent page open a child page in modal popup mode, and when I close the child page, the parent page reload it) BUT IF OPEN MY SITE WITH A IE 6.0, I RECIVE THE MESSAGE:<span style="font-family:Verdana, Arial, Helvetica, sans-serif"><span style="white-space:normal"><span style="font-family:monospace"><span style="white-space:pre"><pre lang="x-c#"><%@ Page Title="" Language="C#" MasterPageFile="~/MasterPager.Master" AutoEventWireup="true" CodeBehind="LineDetails.aspx.cs" Inherits="BillerManager.Web.UI.Portal.Forms.LineDetails" %> <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <script language="javascript" type="text/javascript"> function reloadParentAndClose() { window.close(); } </script> <table width="100%" style="background-color: white;"> . . .
"Internet Explorer cannot open the Internet site http://....Operation Aborted"I recive this message when I open my site, in default.aspx. And I recive it only when open my site with IE 6.0. If I open it with 7.0 or 8.0 I've not problem.If i cut the <base target="_self" /> from my Master.Page, I don't revice any error but when i close my modal popup, a new window is open with the same page......Any idea????? - Thanks a lot
This code help me very much - I tried base under head. It works fine in IE6. But in IE 7, the same problem is there. How to rectify that?


