HTML : Simple back button

<a href=”#” onclick=(history.back())>Back</a>

Enjoy its simplicity.

ASP:HTML to Word plus dynamic database and page break

Effectively to take information from either HTML or a database and put it in a new Word document, we have to make a new ASP page in the browser, and then open it with Microsoft Word. The main bit of code used is as follows :

<%

Response.ContentType = “application/msword”

Response.AddHeader “Content-Disposition”, “attachment;filename=filename.doc”

%>

Everything else we just use response.write to fill the body of the text. But if you want the document to be nice and structured, I would advise placing in the following before the main body.

<%

Response.write(“<html ” & _

“xmlns:o=’urn:schemas-microsoft-com:office:office’ ” & _

“xmlns:w=’urn:schemas-microsoft-com:office:word’” & _

“xmlns=’http://www.w3.org/TR/REC-html40’>” & _

“<head><title>”)

Response.write(Title of Document)

Response.write(“</title>”)

Response.write(“<!—[if gte mso 9]>” & _

“<xml>” & _

“<w:WordDocument>” & _

“<w:View>Print</w:View>” & _

“<w:Zoom>90</w:Zoom>” & _

“<w:DoNotOptimizeForBrowser/>” & _

“</w:WordDocument>” & _

“</xml>” & _

“<![endif]—>”)

Response.write(“<style>” & _

“<!— /* Style Definitions */” & _

“@page Section1” & _

” {size:8.5in 11.0in; ” & _

” margin:1.0in 1.25in 1.0in 1.25in ; ” & _

” mso-header-margin:.5in; ” & _

” mso-footer-margin:.5in; mso-paper-source:0;}” & _

” div.Section1” & _

” {page:Section1;}” & _

“—>” & _

“</style></head>”)

%>

Next you can just structure the document with HTML tags. Any way you would structure a website it should appear the same in the Word document.

<h1>Heading</h1>

<p>Paragraph1<b>bold text</b></p>

<p>Paragraph2<i>italic text</i></p>

And that’s the basics of it. Now if you want to take information from a database and print it out on a document. Like you might have a dynamic website were the users generating the content. Any script that pulls information from the database to display content, as long as it works in ASP it will work with this method. In my case I used a database call to get users profile information as displayed as I would display it on the website. If you have an ID tag to label content in a database, this method with display the information the same as it does on any webpage

<!—#INCLUDE virtual=”NameOfDatabaseCall.asp”—>

If you are pulling lots of information into the document, you might want to break it up on to different pages. Like if you were pulling information on different topics and on each topic you want to start a new word page. You need to put a page break into your ASP code at the end of whatever loop you are using.

<br clear=”all” style=”page-break-before:always” />

Making your links open a new window

If you are using Tumblr or any CMS to promote your portfolio, it makes sense to have your links to other sites open new windows or tabs. This means people will still have your portfolio open in their browser so they can still view other parts of your portfolio later.

Any web developer should know this already, but I will explain it briefly for other people that have websites as well and may not know HTML.

You need to add target=”_blank” into your active link enclosed by tags. So a href=”http://www.donroche.com” becomes a href=”http://www.donroche.com” target=”_blank”  .

In my previous post Adding Linkedin button to your website or Tumblr, I showed you how to add Linkedin buttons to your blog or Tumblr. I slipped this handy little code into the link and made it that much more efficient.