Tuesday, September 30, 2003

Open maximised window (JavaScript)

The following will open a maximised window, with scrollbars, menubar, but no toolbar (only works with links to pages on the same site - ../folder/file.htm or /folder/file.html not http://www.google.com - Access denied error will occur):

function showDocument(sDocURL){
	var newwin = window.open(sDocURL,'newwin','scrollbars=yes,toolbar=no,menubar=yes');
	return false;

Call function as follows: <a href="../folder/file.htm" onclick="showDocument(this.href); return false">File</a>
Will set focus on page and replace any existing page that was called in the same way.

Monday, September 29, 2003

Convert ASP page to Microsoft Word document

Insert the following at the top of an ASP page to convert it to a Word document (Word 97+ required on client desktop). It uses Microsoft Word's HTML parser to generate the page.

Response.ContentType = "application/msword";
Response.ContentType = "application/msword"
Response.AddHeader "Content-Disposition","attachment;filename=filename.doc"

Note that only the text will be saved if you save the file to disk (i.e. images will not be downloaded and embedded into the document)

Tuesday, September 23, 2003

CSS Design

css Zen Garden: The Beauty in CSS Design site layouts done in CSS - all images that are displayed on the page are defined in the style sheet. It shows that you can add images to pages using nothing but CSS.

Other CSS Sites:

Monday, September 22, 2003

Delete file (ASP)

Delete file using ASP JScript (pass filename on in form [hidden input called 'deletefile'] or QueryString [page.asp?deletefile=myfile.doc]):

// delete file
var oFSO = Server.CreateObject("Scripting.FileSystemObject");
// get path to file (relative to current document)
sPathToFile = Server.MapPath("/path/to/upload/folder/"+Request("deletefile"));
// if file exists, delete it 
if(oFSO.FileExists(sPathToFile)) oFSO.DeleteFile(sPathToFile)
// file deleted
Or using ASP VBScript
' delete file
Dim oFSO, sPathToFile
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
' get path to file (relative to current document)
sPathToFile = Server.MapPath("/path/to/upload/folder/"&Request("deletefile"));
' if file exists, delete it 
If oFSO.FileExists(sPathToFile) Then oFSO.DeleteFile(sPathToFile)
' file deleted

N.B. Folder must have modify permissions set for the Internet Guest Account (normally IUSR_MACHINENAME)

Connect to Database (ASP)

The following connects to a database with ASP JScript:

// create connection
var oConn = Server.CreateObject("ADODB.Connection");
// open connection to database
// generate SQL
sSQL = "SELECT * FROM tablename";
// create recordset from SQL
var oRS = oConn.Execute(sSQL);
// work with recordset
// close recordset and connection

And with ASP VBScript:

Dim oConn, sSQL, oRS
' create connection
Set oConn = Server.CreateObject("ADODB.Connection")
' open connection to database
' generate SQL
sSQL = "SELECT * FROM tablename"
' create recordset from SQL
Set oRS = oConn.Execute(sSQL)
' work with recordset
' close recordset and connection
Set oRS = Nothing
Set oConn = Nothing

Sunday, September 21, 2003

Folder Size Browser program

Found this .NET program that shows folder sizes for the various drives in My Computer: Folder Size Browser program.
.NET Framework Required

Folder Size Shell Extension adds to the properties dialog of all folders the amount of space that is used up - this is good, but a standalone utility (i.e. running off a floppy disk) will also be good.

Friday, September 19, 2003


Blogger sites Blogging tools

Wednesday, September 10, 2003

ASP.NET Forums / Groups

Some ASP.NET discussion groups: Newgroups (via Google)