How to print the whole asp.net webpage on a 开发者_开发百科single button click event using VB?
No Server side code required.you can use javascript inbuilt function print().
<input type=button name=print value="Print" onclick="javascript:window.print()">
EDIT:
If you are using server control button then create a javascript function and call this function on OnClientClick event.
<script type="text/javascript">
function PrintPage() {
window.print();
}
</script>
<asp:Button ID="btnPrint" runat="server" Text="Print" OnClientClick="javascript:PrintPage();" />
Why use VB for this? Printing is a client-side operation, just call window.print()
in JavaScript. Here are some examples.
精彩评论