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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calling ASP from HTML

Status
Not open for further replies.

jgraves13

Programmer
Jan 31, 2007
42
US
Is it possible to call an ASP function from html, just like javascript?

JG
 
I need to do this either in a dreamweaver template or using the <body onLoad> tag.
 
You could submit an HTML <form> to an ASP.

You could also make an HTML <a href="">link</a> to an ASP.

But you cannot just call an ASP function because the page is done running.
 
Remember the timeline:

1. Browser sends HTTP request to Server.
2. Server gives the Request to ASP.
3. ASP logic runs to prepare an HTTP Response.
4. ASP gives the Response to the Server.
5. Server returns the Response to the Browser.
6. Browser renders the Response as a web page.

By the time you get to step 6, the ASP is done running and the Server has moved on to some other task.
 
is there a way to have the body onLoad make the call for asp to return a date function???
 
What exactly are you wanting to do?

You can call the function within a block of ASP code that writes HTML.

Example:

Code:
<body>
<div>
garbage
</div>
<%
   Response.Write("<div>");
   functionCall();
   Response.Write("</div>");
%>
</body>







[monkey][snake] <.
 
The onLoad event occurs only in the browser.

The ASP doesnt know the difference between HTML, CSS, and client-side script.

Suppose the ASP looks like this...[tt]
<body style="color:red;" onLoad="alert('The date is: <%= cStr(Date) %>');">[/tt]

What the browser actually receives will look like this:[tt]
<body style="color:red;" onLoad="alert('The date is: 3/26/2007');">[/tt]

As far as the ASP is concerned, this is all plain text that will be sent to the Browser as an HTTP Response.

... but the Browser will see:
An HTML element: [blue][tt]<body>[/tt][/blue]
CSS instructions: [blue][tt]color:red;[/tt][/blue]
An DOM event with client-side JavaScript: [blue][tt]onLoad="alert('The date is: 3/26/2007');"[/tt][/blue]

 
It is probably more trouble than its worth for a date but...

Many popular browsers include a feature for parsing XML. Included in this code is the ability to request addition chunks of XML from the server WITHOUT reloading the page. It is possible to take advantage of this feature to create a crude remote procedure call. There is even an acronym for this technique: AJAX. See google for details.
 
Here is my real issue, I am trying to find a suitable work around for displaying the copyright 1997 - 2007. My issue is I can no longer use AJAX or javascript to do this. I have a 100+ pages to update. So I am looking of alternatives to this like reading in a file to html to grab the 2007. Or set a script tag to call asp like javascript.... Did I explain it okay?

JG
 
Perhaps an "include" file would be good. This allows you to insert the same file into multiple pages. If the data changes in the future, you only need to change the one file, and the effect will be seen on all pages.

See here:
Also you could make it dynamic so that the lastest year will always been shown:[tt]
Copyright 1997 - <%= Year(Now) %>
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top