0

In ASP.NET Web Application, there is a main window (Default.aspx or home page) and there is a child window(a new aspx page). When I open child page with javascript on a button click using window.open() method by specifying its url. C# code on Button Click Event:

protected void BtnChildPage_Clicked(object sender, ImageClickEventArgs e)
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        sb.Append(@"<script language='javascript'>");
        sb.Append(@"OpenChildPage('" + sQueryString + "')");
        sb.Append(@"</script>");

        //register startup script with button
        ScriptManager.RegisterStartupScript(BtnPartMemo, this.GetType(), sScriptName, sb.ToString(), false);
    }

Javascript code to opne Child Page:

var childmWindow;
function OpenChildPage(sQueryString) {

    var width = 655;
    var height = 508;
    var left = (screen.width - width) / 2;
    var top = (screen.height - height) / 2;
    var params = 'width=' + width + ', height=' + height;
    params += ', top=' + top + ', left=' + left;
    params += ', directories=no';
    params += ', location=no';
    params += ', menubar=no';
    params += ', resizable=yes';
    params += ', scrollbars=yes';
    params += ', status=yes';
    params += ', toolbar=no';
    childmWindow = window.open('DirectoryName/ChildPage.aspx' + '?ViewerId=' + sQueryString,
                                'Child Page' + sViewerId, params);
    childmWindow.focus();

}

The child window doesn't appear in front of main window. I tried window.focus() after calling window.open() method but it hides the child window after opening.

This behavior is only observed after deploying application in IIS 5.1 using Win XP. While I execute it from code, it behaves accordingly, but after deploying in IIS, it hides the child window after opening.

How to overcome this behavior ?

2
  • Post your code,otherwise no one can judge the answer.
    – user1776054
    Apr 24, 2013 at 4:46
  • question is updated with code.
    – Itz.Irshad
    Apr 24, 2013 at 5:04

1 Answer 1

0

As far as I understood you need to open child window in small window in front of your main page? If this is correct, then this should help:

window.open('DirectoryName/ChildPage.aspx','_blank', params);

if '_blank' will work but you'll need "'Child Page' + sViewerId" for some reason then

window.open('DirectoryName/ChildPage.aspx','_blank'+'Child Page' + sViewerId, params);

_blank should be used firstly, otherwise it won't work (firstly wanted to comment it but I can't for some reason, so I hope it will help).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.