Printing From Modal Dialogs

L

Lisa

I have an aspx page that has a print button on it. The code for the
Clicked Event of the Print button is:

Dim strScript As String
strScript = "<script language='javascript'>"
strScript += "window.print();"
strScript += "</script>"
Page.RegisterStartupScript("print", strScript)


The aspx page above is opened using the following code from another
aspx page:

strScript = "var windowOptions = 'dialogHeight: 400px; dialogWidth:
600px;
center: yes; help: no; resizable: no; status: no;'; "
strScript += "window.showModalDialog(page.aspx?v1=" + CStr(intVar1) +
"&occ=" + CStr(intVar2) + "&loc=" + CStr(intVar3) + "&total=" +
CStr(intNumBooks) + "&totald=" + CStr(intNumDiagBooks) + "', null,
windowOptions);"

Page.RegisterStartupScript("SuccessScript", "<script
language='javascript'>" + strScript + "</script>")

When compiled and ran locally, the print button will envoke the Print
dialog. If I compile the same code and run it from my server the
button does nothing. Anyone know why and what I can do to fix this?
 
J

Jakub

There can not be postback directly in modal dialogs.
You can for example put your aspx page into iframe in htmlpage or BETTER
replece your server button with something like this :
<button onclick='window.print()'>Print</button>
 
C

Curt_C [MVP]

Perhaps it is your IE security settings. This is all clientside code though,
and not really server so you may want to ask in a javascript group.
 
G

Guest

try this..

<script language="javascript">
window.name = "Popup"
</script>

<form id="Form1" method="post" target="Popup" runat="server">
 
M

Matt Berther

Hello vinay,

This is the same idea as doing

<base target="_self"/>

albeit, much less convoluted...
 

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,755
Messages
2,569,536
Members
45,017
Latest member
GreenAcreCBDGummiesReview

Latest Threads

Top