Solved

Refresh ASP Page

Posted on 2002-07-29
12
709 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 2

Accepted Solution

by:
Hooligan earned 25 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now