 |
| Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

August 31st, 2004, 01:19 PM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Skip On Refresh
I have these line of code .First time in Internet Explorer all these lines will excute. I want that if user clicks on the refresh button these line of coded should skip. Is there any solution of my problem. if yes then pls reply me..
<%
dim rs1,rs2
set rs2=server.CreateObject ("adodb.recordset")
set rs1=server.CreateObject("adodb.recordset")
rs1.Open "select * from QQ1to75",con
rs2.Open "select * from answer",con,adOpenForwardOnly,adLockOptimistic,adc mdtxt
while not rs1.EOF
rs2.AddNew
rs2("Q_id")=rs1("Q_id")
n1=Request.Form("radio"&rs1("Q_id"))
if n1<> "" then
rs2("answer")=Request.Form("radio"&rs1("Q_id"))
else
n1="no"
rs2("answer")=n1
end if
rs2.MoveNext
rs1.MoveNext
wend
rs1.Close
rs2.Close
set rs1=nothing
set rs2=nothing
%>
Thanks
Prabhakar
Prabhakar Kumar
__________________
Prabhakar Kumar
|
|

August 31st, 2004, 01:51 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Hey,
I don't think so; I don't think you can code in features from IE... Maybe with a javascript solution, but that might be very tricky.
Brian
|
|

August 31st, 2004, 01:59 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
You can't do this. There's no difference to the server (or the browser) to the first hit to a page or a refresh.
You could set some kind of cookie or session variable when the page it hit... and then look for it as an indicator that a refresh has taken place...
Hal Levy
Web Developer, PDI Inc.
NOT a Wiley/Wrox Employee
|
|

August 31st, 2004, 06:15 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
When I faced this issue I was told at first, it cant be done (on a JS forum). Using session variables wrapped in conditional statements was my initial thought, this worked. Then I started exploring the onLoad event of the body tag, I'm fairly sure this is what I settled on - will try and find the page and let you know. I think the server side is a more relyable method personaly.
Wind is your friend
Matt
|
|

August 31st, 2004, 11:23 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
The best method to tackle this situation is to introduce an intermediate page. The activities of above page are done in the intermediate page and at the end you can redirect to a feedback page. The page that is shown in browser should not do any activity other than printing-out some feedback.
This also helps to seperate HTML and ASP to a certain degree.
|
|

August 31st, 2004, 11:29 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
A complicated option, how can you redirect after sending headers?
Wind is your friend
Matt
|
|

September 1st, 2004, 11:30 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
No, you should not write anything to the browser. The code that he has shown is not writing anything to browser.
Otherwise, buffer should be set. This is not a best nethod.
With a properly designed pages, the above solution is not a complicated one, I think. I have been using this type of coding in all my pages.
For a purpose, you will have one display page and a set of action pages. The display page will submit a form to an appropriate action page. The action page will re-direct to the display page with an appropriate message.
For eg. Suppose it is an employee mgmt. problem. There will be a page which displays all employees (with paging) in a table. Below which, there is a form to add/edit an employee. Then there will be 4 action pages 1) validation 2) add, 3) delete 4) modify. The display page will submit either the list form(list of employees) or the form below to appropriate action pages. At the end of action, it will redirect to display page saying "successfully added" etc. This can be applied to other situations also. I have not found any situation which will not fit into this method.
This method , I have adopted from the fusebox ( http://www.fusebox.org)concepts of coldfusion. This method will give an easily maintainable set of pages also.
|
|

September 1st, 2004, 11:48 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
You will achieve results using either way. Neither are best methods, these are two people styles of achieving a result.
Hal said: 'You can't do this'
madhukp said: 'The best method to tackle this situation is....'
Both of the statements above are in correct, this I do know. It can be done and neither of the methods illustrated above are 'best'
Another example of different styles. The 'employee mgmt' example above I would code all on the one page. There is no right or wrong ways, just ones that work, or do not.
Wind is your friend
Matt
|
|

September 2nd, 2004, 05:56 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
1) As Hal said, it can be done using session/cookie values set.
2) As Madhu said, it can be done using another page containing this code and redirecting to this page. I wouldn't call it an intermediate page, as this would be the landing page, which on completion redirects to the other page, and on click of refresh button, it would always refresh the page that you are lastly in.
IMO, this can be done, not sure if that is a work around/complicated option/the only way of approach to do this.
I would say Hal's suggestion would be a beter one for this. As, once the session/cookie variable is set, you cannot get this set of code to execute the second time, unless the browser is closed or session/cookies expires. But in madhu's case, if you can somehow make out the url of that intermediate page, the you can call that to execute this set of code again from the address bar.
Now the choice is left to Prabhakar.;)
Hope that helps.
Cheers!
_________________________
- Vijay G
Strive for Perfection
|
|

September 2nd, 2004, 11:44 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
But, I cannot agree with Hal's idea of using session for these purposes. What if session or cookie is not enebled on the browser ?
If there are 25 such forms in a site, this means you should need 25 different session variables. You cannot re-use the variables as you cannot be sure which all forms are now open. People can open a site in more than one window and fill two or more forms simultaneously.
I didn't understand the last comment. The user can get the name of the intermediate page from the display page. But what he can do with it ? He may be able to submit a similar form to that page but he cannot change the re-direction behaviour of that page. This is possible if we use direct page also.
To enhance the security, you may check the coming page (referrer page) in the intermediate page and then do the actions.
To completely obscure all the filenames, we may have to use some fusebox techniques.
|
|
 |