Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call ASP code on page load event

Status
Not open for further replies.

scribbler

MIS
Feb 4, 2002
206
0
0
GB
Please can anyone tell me how to call an asp procedure from the onload event. I have to execute some code which requires the page to be loaded first and I have very little knowledge of javascript.
 
Thanks for the reply Dan

I have a nagging problem in that, using asp, I send a user via email some information and allow them, via a hyperlink, to download a word document which works fine so far but my problem is that once the user has downloaded the document there is a blank window left on screen. Is there any way to close this down after a download or even prevent the window from opening in the first place.

I have tried to place a "click here to close this window" but my asp code appears to override this in that it allows the download dialog box to display and downloads the document but the screen behind is blank. hence the reason for my initial question as I was trying to use the javascript code to call the code then close the window afterwards.
 
Dan
Not quite sure what you mean. I send an email to the user containing a hyperlink to a ASP page which then has the code to download the document. Ive taken out my javascript to close the window only because the ASP code fired up with the download dialog box and then no html/javascript was left on the opened window behind.

Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
response.write ("This page is confirmation of your request to download a finance proposal document from our server.<br><br>")
	path="C:\Program Files\test.doc"
	set fso=Server.CreateObject("Scripting.FileSystemObject")
	set f=fso.OpenTextFile(path)
	data=f.ReadAll
	ext=fso.GetExtensionName(path)
	if ext="pdf" then
	 Response.ContentType="application/pdf"
	elseif ext="doc" then
	 Response.ContentType="application/msword"
	'Response.AddHeader "Content-Disposition"," attachment; filename=" & "test.doc"
		If Request.QueryString("ID")="Business" Then 'Allow Download Of Business Proposal 
			Response.AddHeader "Content-Disposition"," attachment; filename=" & "rc_companyproposal.doc"
			Response.BinaryWrite data
		ElseIf Request.QueryString("ID")="Consumer" Then 'Allow Download Of Consumer Proposal 
			Response.AddHeader "Content-Disposition"," attachment; filename=" & "rc_consumerproposal.doc"
			Response.BinaryWrite data
		End IF
	End if

	Set f = Nothing 
	Set fso = Nothing 
%> 
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<BODY>
</body>
</html>
 
Not quite sure what you mean.

I wanted to know if the URL you gave the user (in the email) linked directly to the .DOC file or not.

I had assumed from what you said:

I send a user via email some information and allow them, via a hyperlink, to download a word document

that you sent the user an email, with a link (URL) to a word document (.DOC file). From what you have now said, it is clear that this is not the case, and you actually link to an ASP file instead of directly to the .DOC file.

One potential solution would be to target the link in the emails BEFORE sending them out, rather than doing the logic when the link is clicked. Basically, send emails with a link to the relevant .DOC file. This would avoid the blank window, I'd say, without the need for extra JavaScript code.

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks for replying Dan but I'm unsure how to achieve this as I have little programming knowledge "Basically, send emails with a link to the relevant .DOC file" are you able to provide me with some info on how to do this ? I'm one of those "spell it out for me" I'm afraid.
 
I have no knowledge of the system you use to craft or send your emails, so I can't really say how you should do it... but in basic terms, what I am suggesting is:

- Split the mailshot into two groups:

- 1. A group of people who need to recieve the rc_companyproposal.doc, and
- 2. A group of people who need to receive the rc_consumerproposal.doc.

Currently, I assume you only have 1 group, who all get the same link to the same ASP page.

- Now you have defined your two distinct mailshot audiences, instead of sending the mail with a link to an ASP page (which deteremined which of the two .DOC files to present), send group 1 a direct link to the "rc_companyproposal.doc" file, and send group 2 a direct link to the "rc_consumerproposal.doc" file.

If this doesn't make sense, I think you'll have to either ask the person in charge of creating the mailshots or ASP pages to step in, or take this to the relevant forum for the program you use to create or send your mailshots. I don't think JavaScript can help you at all with the route I'm suggesting.

Of course, if you still wish to do it with JavaScript, someone else may be able to suggest a method that does work.

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top