.NET Framework Bookmark and Share   
 index > JScript for the .NET Framework > window.showModalDialog problem
 

window.showModalDialog problem


I have button onSearch.aspx page. when user clicks on that button a new window appears
using following javascript

function 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.aspx

im using following c# code in click event of select button

private void MemberDetails1_SelectorChanged(object sender, ProgramEventArgs e)
{
// some code here

Response.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.

lax4u

add this line to the child window page html...

<base target="_self">

kjames

i'll put above question in simple way

i have Main.aspx page with one button.
On click event it will execute following javascript code

function ShowDialog()
{
window.showModalDialog("Child.aspx");
}


on child.aspx i have one more button
on click event it will execute following javascript code

function CloseDialog()
{
window.close();
}

why its not closing Child window and control is also not going back to main window.

lax4u
Hey lax4u

Try this,

var childWindow;

function ShowDialog()
{
childWindow = window.showModalDialog("Child.aspx");
}

function CloseDialog()
{
childWindow.close();
}

Hope this helps.
a.Net Person

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!

dlliu

add this line to the child window page html...

<base target="_self">

kjames
kjames wrote:

add this line to the child window page html...

<base target="_self">

KJames

Can you elaborate this further!

smomair

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.

gauravsatya

use this,

"window.dialogArguments.location.href = ''

and then window.close

hope it helps

sahridhayan

sahridhayan

use <base target="_self" /> under head section

Tabrez Khan

Hi

thank u.u helped me so much.

lakshmideepthi

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!!

diffident
thanks a lot, it really worked by placing <base target="_self"> in the head section.


thanks once again.

ShadowMan : The Lord of Dead Side
Harshil_Patel_5326c0

Is it ok? <base ...>?

Mr Bin

Thanks every body....
I was alsoworring for the same.
anyway it helped me a lot.

EJAZMOHAMMED
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 button

<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;">
.
.
.


This 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:

"
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?????
John Writers
Thanks a lot
This code help me very much
OponCodes

You can use google to search for other answers

Custom Search

More Threads

• Support for E4X anytime soon?
• call variable from HTML
• I want to nest tables down to 50+ levels, but I can get 26~27 levels in Internet Explorer at most, but 33 levels in firefox, can anyone help?
• Screen Capture usig JavaScript
• JScript
• How can I invoke an EXE from Web...
• code to run flash movies ,its working on firefox but not on explorer WHY?
• current date in textbox
• how to print mutiple pages of a gridview using javascript
• javascript function problems