Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Refresh ASP Page

Posted on 2002-07-29
12
Medium Priority
?
724 Views
Last Modified: 2012-06-21
In an ASP page I am traping a onchange event on input box and  calling a VBScript function for this event.

here I am setting a Hidden box value to '1'.

In the asp I am geting this hidden box value by request.form and if it is '1',  I am using a function of my own com object. It is working fine.

I am using VBscript at the end of the ASP to reset it to '0'

But after this If I press Refresh / F5 button the hidden box value is still '1'. So calling the com funtion again.

I want to call the function only onchange event and not on refresh. ASP gives hidden box value as "" on first launch and on refresh it gives '1'.

Is there any function in ASP that runs while the user presses the Refresh/F5 button?

Regards.
Viswanath.
0
Comment
Question by:viswanathat
12 Comments
 
LVL 39

Expert Comment

by:appari
ID: 7185007
as far as i know there is no  function in ASP that runs while the user presses the Refresh/F5 button.

anyway you are setting the hidden variable to 1 on change event, always  assign "" from asp page instead of assigning 1 on refresh. that should work.



0
 

Author Comment

by:viswanathat
ID: 7185082
Dear appari

   Tanx..  

i have to call a com function onchange event only.
for this i am using a hidden box and changing the value on change

on first launch the value doesn't mactch and the function  is not called .. it's ok

onchange the value changes and the function is called. it's ok.

on refresh button click the request.form returns the same value in the input box even though i reset it.

how can i set a ASP variable from a event based vbscript?
so that i can call the COM function on this event only?

or how to call COM function from event based script?

Regards.
Viswanath.

0
 

Expert Comment

by:gingiGuy
ID: 7185089
You could use cookies to record the number of times the user has visited the page, and extraploate from that if they pressed refresh.
The same could be acheived with session variables.

in session_onstart() (in the global asa), you could create a variable

session("IsFirstTime") = true

Then when the user reaches your pages you can test for the value of this variable, then do

session("IsFirstTime") = false

so that if the pages is called again (ie refereshed) it would not execute that code inside your testing block

Hope this is of some help, or that you can get some other ideas from this.

Guy
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 39

Expert Comment

by:appari
ID: 7185299
can u post your function you were calling onchange event.
0
 
LVL 39

Expert Comment

by:appari
ID: 7185304
can u post code of your function you were calling onchange event.
0
 
LVL 18

Expert Comment

by:bruno
ID: 7185758
you would have to do something on the body onload event to check what the value was....
0
 
LVL 2

Accepted Solution

by:
Hooligan earned 75 total points
ID: 7185856
not sure im clear on the problem, but if i am reading it right, why dont you just set the value of the hidden field back to whatever value it needs to be at the end of your onChange event function?
0
 

Author Comment

by:viswanathat
ID: 7187095
it is like this : Here the com function is called again in refresh after first onchange. how to prevent this..?
copy this to a .asp file and pls check.

one simple solution is to call another asp onchange to call the com function and return to this asp. Then any parent asp refresh does not call the com function but it does simple refresh.

Regards.
Viswanath.

<HTML>                    
<body>
<form name = "Form1" method="post"  action="test.asp">

<%  Response.write "Change and press tab : <input type= text name= Curval  OnChange= ""onenter(  this.value );"" value = "  & 5 & "><BR>"

Response.write  "<INPUT TYPE=text name = EnterPressedHidden  value = " & Request.Form("EnterPressedHidden")&"> "

Response.write   Request.Form("EnterPressedHidden")
if(Request.Form("EnterPressedHidden") = 1) then
     Response.Write "Call COM function here only onchange"
end if  
%>

<SCRIPT LANGUAGE=VBScript >      ' reset the value to zero.
document.Form1.EnterPressedHidden.value = 0    
</SCRIPT>

</FORM>

<SCRIPT LANGUAGE=VBScript   > 
function onenter(val)
     document.Form1.EnterPressedHidden.value = 1
     document.Form1.submit()       'calls same asp
end function
</SCRIPT>
</body>
</HTML>

0
 
LVL 39

Expert Comment

by:appari
ID: 7187106
try this

remove this
<SCRIPT LANGUAGE=VBScript >      ' reset the value to zero.
document.Form1.EnterPressedHidden.value = 0    
</SCRIPT>

change this line to
Response.write  "<INPUT TYPE=text name = EnterPressedHidden  value = ''> "
0
 

Author Comment

by:viswanathat
ID: 7187133
dear appari

if you write Response.write it will creat another text box with same name.. the onenter() will get confused to set value to which box..

here i am writing script without any function so that it is called on the end of asp to reset the value.

Regards.

Viswanath AT.
0
 
LVL 39

Expert Comment

by:appari
ID: 7187181
Sorry, what i mean is
change
Response.write  "<INPUT TYPE=text name = EnterPressedHidden  value = " & Request.Form("EnterPressedHidden")&"> "
to
Response.write  "<INPUT TYPE=text name = EnterPressedHidden  value = ''> "

and remove the block

<SCRIPT LANGUAGE=VBScript >      ' reset the value to zero.
document.Form1.EnterPressedHidden.value = 0    
</SCRIPT>

0
 
LVL 58

Expert Comment

by:Gary
ID: 8845753
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept Answer by Hooligan
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
GaryC123
EE Cleanup Volunteer
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question