Print Function Doesnt Work.

5 posts, 1 answers
  1. Velkumar
    Velkumar avatar
    85 posts
    Member since:
    Apr 2011

    Posted 03 Nov 2011 Link to this post

    Hi

                I am using radbutton in my page for printing the web page. I have using the the javascript function   OnClientClicked="javascript:self.print();return false;"   for printing. But it didn't  work. If i am using HTML or ASP button then it will work properly. Please give the solution for this problem.

    Thanks,
    Velkumar
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="PrintDemo.aspx.cs" Inherits="PrintDemo" %>
     
    <%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <head runat="server">
        <title></title>
     
        <link rel="stylesheet" href="PrintStyleSheet.css" type="text/css" />
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
            </telerik:RadScriptManager>
            <table style="width: 877px">
                <tr style="height:20px; vertical-align:middle;"  >
                    <td align="center" id="headid">
                        <asp:Label id="Heading" Text="Print checking " runat="server"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td align="center">
                        <asp:Label ID="printContent" runat="server"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="height:20px;">
                 
                    </td>
                </tr>
                <tr>
                    <td align="center">
                        <telerik:RadButton ID="printbtn" Text=" Print " OnClientClicked="javascript:self.print();return false;"  runat="server"></telerik:RadButton>
                    </td>
                </tr>
                <tr>
                    <td align="center">
                       <asp:Button ID="printbutton" OnClientClick="javascript:self.print();return false;" Text="Print" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td align="center">
                        <input type="button" value="Print" onclick="JavaScript:window.print();" />
                    </td>
                </tr>
            </table>
        </div>
        </form>
    </body>
    </html>
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 04 Nov 2011 Link to this post

    Hello Velkumar,

    The properties that are used to specify the RadButton's (or any RadControl's) client-side events, like OnClientCliking, OnClientClicked and etc., expect the name of the JavaScript function to be passed. So, whenever you handle client-side events of the RadControls for ASP.NET AJAX, pass only the name of the function.
    OnClientClicked

    Thanks,
    Shinu.
  3. Velkumar
    Velkumar avatar
    85 posts
    Member since:
    Apr 2011

    Posted 04 Nov 2011 Link to this post

    Hi,

    Now i am using the client function like this. This also not working.

    <telerik:RadButton ID="printbtn" Text=" Print " OnClientClicked="btnClick;return false;"  runat="server"></telerik:RadButton>

    I Post the the asp and javascript code below

    <telerik:RadButton ID="printbtn" Text=" Print " OnClientClicked="btnClick;return false;"  runat="server"></telerik:RadButton>
    <script type="text/javascript" language="javascript">
        function btnClick(sender, args) {
     
            window.print();
         
        }
    </script>


    Thanks

    Er.Velkumar
  4. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 06 Nov 2011 Link to this post

    Hello Velkumar,

    The correct method of calling a client function for RadControl is as follows.
    <telerik:RadButton ID="printbtn" Text=" Print " OnClientClicked="btnClick"  runat="server">
    </telerik:RadButton>
     
    <script type="text/javascript">
        function btnClick(sender,args)
        {
            window.print();
        }
    </script>

    Hope it helps.

    Regards,
    Shinu.
  5. Velkumar
    Velkumar avatar
    85 posts
    Member since:
    Apr 2011

    Posted 17 Nov 2011 Link to this post

    Hi,

       It's Working. Thanks!

    Thanks
    Velkumar.
Back to Top