Link to home
Start Free TrialLog in
Avatar of NBilly
NBilly

asked on

Print an aspx page

I created aspnet aspx page that displays information. I want to put a button on the page to print the content of the aspx page. What coding do I need to do this.
SOLUTION
Avatar of quannv
quannv

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NBilly
NBilly

ASKER

Where would I put this code?  In the code behind?
No in the head of the .aspx page.  It is javascript code.
Avatar of NBilly

ASKER

Do I create a button control on the aspx page.  I want to put a button control on aspx page and when I click on that button have it print the content of the page.

Also, is the <form> and </form> in code my aspx file name.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NBilly

ASKER

mmarksbury,

Your suggestion works.  Now I just want to position that "Pring Page" button in certain place on the aspx page.  How do I do that?
Wherever you put the <INPUT> tag, it should display there.

If you want to add padding, or align it, put it inside of a div and add CSS styling.

For example...

TO ALIGN IT RIGHT:
<div id="ButtonDiv" style="text-align: right;">
  <input type="button" name="PrintButton" onclick="javascript:window.print();" value="Print Page" />
</div>

TO ALIGN IT CENTER:
<div id="ButtonDiv" style="text-align: center;">
  <input type="button" name="PrintButton" onclick="javascript:window.print();" value="Print Page" />
</div>

TO ADD PADDING:
<div id="ButtonDiv" style="padding: 12px;">
  <input type="button" name="PrintButton" onclick="javascript:window.print();" value="Print Page" />
</div>

Once it is inside the div, you can position it and stylize as needed.
Avatar of NBilly

ASKER

mmarkbury,

I got it working the way I want it to work.  Thank you.