Can't close the popup window from codebehind...

M

Mahernoz

Hi Friends,

I simply want to print a report by opening a popup, calling the print
function and closing the window after the user has printed the
report.

I have 2 functions.... in c#

The Onload event registers a script to close the window from c#. The
FillReport functions fills a gridview

I have a JavaScript Function AssignContent(); which simply calls
window.print() and window.close()

This code runs fine in Firefox but the window is not closing in
Internet Explorer 6

I am also giving the code ... plz suggest me some solution.. i simply
cannot close the window in ie6.

Here is the code....

C# Code
---------------------------------------------------
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{

fillreport();
if (!ClientScript.IsClientScriptBlockRegistered("k1"))
{
ClientScript.RegisterClientScriptBlock(this.GetType(),
"k1", "<script language='javascript'>AssignContent();</
script>");
}
}
}

private void fillreport()
{
//fills a gridview
}



//JavaScript
-------------------------------------
function AssignContent()
{
window.print();
window.close();
}




Regards,
Mahernoz
 
M

Merennulli

Hi Friends,

I simply want to print a report by opening a popup, calling the print
function and closing the window after the user has printed the
report.

I have 2 functions.... in c#

The Onload event registers a script to close the window from c#. The
FillReport functions fills a gridview

I have a JavaScript Function AssignContent(); which simply calls
window.print() and window.close()

This code runs fine in Firefox but the window is not closing in
Internet Explorer 6

I am also giving the code ... plz suggest me some solution.. i simply
cannot close the window in ie6.

Here is the code....

C# Code
---------------------------------------------------
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{

fillreport();
if (!ClientScript.IsClientScriptBlockRegistered("k1"))
{
ClientScript.RegisterClientScriptBlock(this.GetType(),
"k1", "<script language='javascript'>AssignContent();</
script>");
}
}
}

private void fillreport()
{
//fills a gridview

}

//JavaScript
-------------------------------------
function AssignContent()
{
window.print();
window.close();
}

Regards,
Mahernoz

I suspect it's a timed security measure. I can easily see someone
posting a link to a page that pops up hundreds of windows like that in
short order, leaving you with a hyperactive printer and nothing on the
screen to say why. Try putting the close on a timer instead of
occurring so soon after the page loads.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top