By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,587 Members | 1,079 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,587 IT Pros & Developers. It's quick & easy.

Printing From Modal Dialogs

P: n/a
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?
Nov 19 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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>
"Lisa" <li**********@gnb.ca> wrote in message
news:fd*************************@posting.google.co m...
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?

Nov 19 '05 #2

P: n/a
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.

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Lisa" <li**********@gnb.ca> wrote in message
news:fd*************************@posting.google.co m...
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?

Nov 19 '05 #3

P: n/a
Hello Lisa,

Try putting <base target="_self"/> in the .aspx for your dialog.

--
Matt Berther
http://www.mattberther.com
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?

Nov 19 '05 #4

P: n/a
try this..

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

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


"Lisa" wrote:
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?

Nov 19 '05 #5

P: n/a
Hello vinay,

This is the same idea as doing

<base target="_self"/>

albeit, much less convoluted...

--
Matt Berther
http://www.mattberther.com
try this..

<script language="javascript">
window.name = "Popup"
</script>
<form id="Form1" method="post" target="Popup" runat="server">

"Lisa" wrote:
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?

Nov 19 '05 #6

P: n/a
U are right :)

"Matt Berther" wrote:
Hello vinay,

This is the same idea as doing

<base target="_self"/>

albeit, much less convoluted...

--
Matt Berther
http://www.mattberther.com
try this..

<script language="javascript">
window.name = "Popup"
</script>
<form id="Form1" method="post" target="Popup" runat="server">

"Lisa" wrote:
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?


Nov 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.