how to check printer installed on the current system by javascript?

Last post 05-19-2008 12:52 AM by samuelchandradoss. 5 replies.

Sort Posts:

  • how to check printer installed on the current system by javascript?

    05-17-2008, 3:45 AM

    i have tried to print a page through client button click event.but it shows an error as printer has not installed.so i want to check whether printer is installed on this computer or not.if yes i want to proceed else alert the user.

    this i want to do in javascript.. 

    Before you can perform printer-related tasks shch as page setup or printing a document,you need to install a printer. do you want to install a printer now? .

    Thanks & regards

    SAmuel Chandradoss John
  • Re: how to check printer installed on the current system by javascript?

    05-17-2008, 5:14 AM

    Javascript has no access to printer properties, so you can't do this.  You would need to develop a control that runs in the client browser, such as an ActiveX control, and you need them to download and install it.

     

    Regards Mike
    [MVP - ASP/ASP.NET]
  • Re: how to check printer installed on the current system by javascript?

    05-17-2008, 5:33 AM
    i think u misunderstood my need. I want to know whether printer is installed or not on the system by javascript .
    Thanks & regards

    SAmuel Chandradoss John
  • Re: how to check printer installed on the current system by javascript?

    05-17-2008, 5:39 AM

    samuelchandradoss:
    i think u misunderstood my need. I want to know whether printer is installed or not on the system by javascript .
     

    No - you misunderstood my reply.  You cannot use javascript to do this.  It has no access to printers, printer properties, the file system or port information on the user's machine.  Therefore, it is impossible to find out by using javascript if a user has a printer installed. 

     

    Regards Mike
    [MVP - ASP/ASP.NET]
  • Re: how to check printer installed on the current system by javascript?

    05-19-2008, 12:46 AM
    use client button to handle the print option .it will catch the system error. problem will be solved.
    Thanks & regards

    SAmuel Chandradoss John
  • Re: how to check printer installed on the current system by javascript?

    05-19-2008, 12:52 AM
    Answer

    function CallPrint( strid ) { try { var prtContent = document.getElementById(strid); var WinPrint = window.open('', '', 'left=0,top=0,width=900,height=600,toolbar=1,scrollbars=1,status=0'); WinPrint.document.write( prtContent.innerHTML ); WinPrint.document.close(); WinPrint.focus(); WinPrint.print(); WinPrint.close(); //prtContent.innerHTML=strOldOne; } catch(err) { alert("hai"); txt+="Error description: " + err.description + "\n\n"; txt+="Click OK to continue.\n\n"; alert(txt); return false; } }

     

    it is the java script to print a content present on the div,

     

     

     

    <div id="divBadWord">
    <CENTER><asp:Label id="lbltBadWords" runat="server" Text="BadWords Report" Font-Size="Large" Font-Bold="true"></asp:Label></CENTER>
    <asp:GridView id="GridViewBadWordsReport" runat="server" Width="667px"
    OnRowDeleting="GridViewBadWordsReport_RowDeleting" OnRowCancelingEdit="GridViewBadWordsReport_RowCancelingEdit"
     OnRowUpdating="GridViewBadWordsReport_RowUpdating" OnRowEditing="GridViewBadWordsReport_RowEditing"
     OnSelectedIndexChanged="GridViewBadWordsReport_SelectedIndexChanged" PageSize="5"
     OnPageIndexChanging="GridViewBadWordsReport_page_Changing" AllowPaging="True"
     AlternatingRowStyle-BackColor="white" GridLines="Vertical" CellPadding="3" BorderWidth="1px"
     BorderStyle="None" BorderColor="#999999" BackColor="White" AutoGenerateColumns="False" Visible="False">
                       <Columns>
                                       
                                       
                                <asp:TemplateField HeaderText="Bad Words">
                              
                                   <HeaderTemplate >
                                        <asp:Label ID = "gvlblBadWords" Text="Bad Words" runat="server" >
                                        </asp:Label>
                                   </HeaderTemplate>
                                  
                                   <ItemTemplate>
                                    <asp:Label ID="lblBadWords" runat="server" Text='<%#Bind("bf_word") %>'  CssClass="title_name2"></asp:Label>
                                    <asp:HiddenField ID ="hidBfid"  Value='<%#Bind("bf_id") %>' runat="server" >
                                   
                                    </asp:HiddenField>
                                   
                                
                                
                                  
                                  </ItemTemplate>
                                  <EditItemTemplate>
                                  <asp:HiddenField ID = "hidBfid"  Value='<%#Bind("bf_id") %>' runat="server" >
                                    </asp:HiddenField>
                                    <asp:TextBox ID="txtBadWords" runat="server"></asp:TextBox>
                                    </EditItemTemplate>
                              
                               </asp:TemplateField>
                              
                               <asp:TemplateField>
                               <HeaderTemplate>
                               <asp:Label ID="gvlbledit" Text="Edit" runat ="server"></asp:Label>
                               </HeaderTemplate>
                               <ItemTemplate>
                             
                                   <asp:LinkButton ID="btnEdit" runat="server" Text="edit" CausesValidation="false" CommandName="Edit"></asp:LinkButton>
                               </ItemTemplate>
                              
                               <EditItemTemplate>
                               <asp:LinkButton ID="btnupdate" runat="server" CausesValidation="false" Text="update" CommandName="Update"></asp:LinkButton>
                               <asp:LinkButton ID="btnCancel" runat="server" CausesValidation="false" Text="Cancel" CommandName="Cancel"></asp:LinkButton>
                             
                               </EditItemTemplate>
                               </asp:TemplateField>
                               <asp:TemplateField>
                               <HeaderTemplate>
                               <asp:Label ID="gvlblDelete" Text="Delete" runat="server"></asp:Label>
                               </HeaderTemplate>
                               <ItemTemplate>
                                <asp:LinkButton ID="lnkbtnDelete" runat="server" CausesValidation="false" Text="Delete" CommandName="Delete"></asp:LinkButton>
                               </ItemTemplate>
                              
                               </asp:TemplateField>
                   
                       </Columns>
                <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
                <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
                <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
                <HeaderStyle BackColor="#AEA89A" Font-Bold="True" ForeColor="Black" />
                <AlternatingRowStyle BackColor="Gainsboro" />
                      
            </asp:GridView></div>

     

             <asp:Button id="btnPrint"  Text="Print Report" onClientClick="return CallPrint('divBadWord')" ></asp:Button>

     


     

    Thanks & regards

    SAmuel Chandradoss John
Page 1 of 1 (6 items)
Microsoft Communities
Page view counter