Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I call a javascript function for print but doesn't work

I use below code for print from Page but doesn't work (means when i click on print button nothing happen). the function doesn't call

 <script type="text/javascript">
        function printing() {
            window.print();
        }
    </script>

protected void print_Click(object sender, EventArgs e)
{
    btnPrint.Attributes.Add("onclick", "return printing()");
}

1 Answers

Try this way:

<asp:Button ID="print" runat="server" Text="Print" OnClientClick="javascript:window.print();" />
like image 165
4b0 Avatar answered May 12 '26 05:05

4b0



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!