This is a migrated thread and some comments may be shown as answers.

Print Function Doesnt Work.

4 Answers 217 Views
Button
This is a migrated thread and some comments may be shown as answers.
Velkumar
Top achievements
Rank 2
Velkumar asked on 04 Nov 2011, 04:53 AM
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>

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 04 Nov 2011, 08:22 AM
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.
0
Velkumar
Top achievements
Rank 2
answered on 04 Nov 2011, 11:17 AM
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
0
Accepted
Shinu
Top achievements
Rank 2
answered on 07 Nov 2011, 05:16 AM
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.
0
Velkumar
Top achievements
Rank 2
answered on 17 Nov 2011, 02:04 PM
Hi,

   It's Working. Thanks!

Thanks
Velkumar.
Tags
Button
Asked by
Velkumar
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Velkumar
Top achievements
Rank 2
Share this question
or