Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2005

Tip: Looking for answers? Try searching our database.

can't use javascript to print in IE6

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
fredd00 - 31 Oct 2005 15:07 GMT
Hi

I have an aspx page that has a datagrid and a print button

i have a javascript function :

function PrintPage(){

    if (window.print) {alert('print');window.focus(); window.print(); }
    else {alert('This script does not work in your browser');}
    //history.back();
    //return false;
}

on the print buton click i have
private void btnPrint_Click(object sender,
System.Web.UI.ImageClickEventArgs e) {

            pnlTopButtons.Visible = false; // hide some buttons
            pnlPrintButtons.Visible = false;// hide some buttons
            pnlUsdQty.Visible=false; // hide some buttons
            Page.RegisterStartupScript("jsPrint","<script
language=JavaScript>javascript:PrintPage();</script>");
        }

the thing is :
<script language=JavaScript>javascript:PrintPage();</script>
is in the page , is the last thing before </form>

the javascript is being called, the alert is fired but not the print
part of the script , no printer dialog box , but in firefox the dialog
box is being displayed.

is it a bug with IE ?, is there a work around ?

thanks i really need this
Eliyahu Goldin - 31 Oct 2005 15:18 GMT
There is no window.print property in IE.

Eliyahu

> Hi
>
[quoted text clipped - 32 lines]
>
> thanks i really need this
Sreejith Ram - 31 Oct 2005 16:40 GMT
Code looks correct to me...  

what happense , if you remove all other lines and use only window.print();
in the  PrintPage() function ?

I think, the only way to find this would be step by step debugging, unless
there is a known MS IE bug.  :)

> Hi
>
[quoted text clipped - 32 lines]
>
> thanks i really need this
fredd00 - 31 Oct 2005 18:39 GMT
if i only leave window.print() , nothing happens
the page is loaded and that's it
Sreejith Ram - 31 Oct 2005 20:59 GMT
But it still works in firefox.. ?.. strange!

I tried the code you posted in first post (only the PrintPage() function ,
not the post back etc) in IE version 6.0.2900.2180 on Win XP SP2  and it
worked just fine..

you may want to try in a different machine, compare IE versions etc

> if i only leave window.print() , nothing happens
> the page is loaded and that's it

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.