ASP code Auto-Run

Hi,

I know this question is quite stupid, but is it possible that ASP codes behind the page will run once through the whole page before the page is display?

Because i had one ASP code inside an VBscript function which will increment a value in the database, which only if i enter that function, am i right?

But i realised that my database increment code did run even without the function running, means that everytime i entered that page, my database auto-increase by 1.

Have anyone have this problem before? Is it something to do with Response.Buffer (i set to false but no effect)?
 
If it's inside a function, it will never be executed unless you call that function somewhere. You might want to check your code if you left any for test calls to the function that you used during development.
 
Ya, i've checked it, i'm very sure i did not call it elsewhere except for the condition on one part of my vbscript that triggers the function.

I did place quite a few line Asp codes in between vbscripts. It will not affect the whole running of vbscripts right?

for example like:

<script>
<%
...
%>

vbscript..

<%
...
%>

vbscripts..
</script>
 
heya,

I've just managed to solved my problem here..

Instead of placing the update database in the page itself because it sure will run no matter where i place the function, i've think i through and decided to place it on another page, for example (Quit.asp)

First by clicking on the hyperlink which is <a href='Quit.asp?vpass=true'>NO (Quit)</a>";

-I've passed vpass=true over to Quit.asp page..

Therefore by requesting ' if vpass = true ' in Quit.asp page, i can activate it=)
 
That's not likely to fix it. If it's being executed without the function being called, it's not within a function :)

Proper indentation can help spot the issue, much like your if / elseif problem :)
 
Hi SubSpace,

Very Sorry if you misunderstand my explanation on the earlier post. Haha

Actually i did not take out the vbscript functions because it has to be there for other codes to work, basically at first because i was thinking of using the vbscript function to update my database (more convenient), therefore i place the ASP code inside the function.

example like:

function ...()
{

<%
.. the Asp database update codes are here...
%>

some vbscripts codes...

}


So it might be because the ASP code above my <body> tag will run once through due to Response.Buffer before my page is display, so i decided to take out the ASP codes inside the vbscript function, and move it instead to another page which is Quit.asp.

Haha, not very sure did i confused you because there's alot of things going on in my mind as i type out to explain and sometimes i might just go out of my point.

And sometimes is due to my lack of elaboration and couldn't express my point well..

But i'm very glad to learn from your guys...
 
I'm not sure what you're trying to do exactly.. It looks like you're mixing JavaScript and VBScript? In that example, yes the ASP will be executed when the page is displayed (since it's not inside a VBScript sub or function), and whatever output is generated is put into the page into a client side JavaScript function.
 
Back
Top