How do i check if my form has been submitted in classic ASP?
Asked
Active
Viewed 1.9k times
15
-
perhaps, check the extension of the referrer – Bill Bingham Jan 24 '10 at 20:00
-
this is an unclear question. what do you want to know ? if the form left the client on its way to the server when you pressed submit ? was the data received as a form (post) and not query string data (get) ? was the data processed by the server with no errors ? too many options here. – shayuna Jul 08 '20 at 18:02
2 Answers
27
First, you can check, if Request.ServerVariables("REQUEST_METHOD")= "POST"
. That is, assuming, you use POST method to submit the form, the initial load will have GET method, the subsequent submits will be POST.
You can also add a hidden field in your form, if that variable is set in POST data (Request.Form
object), you will know it is a postback, otherwise it is the first load.

naivists
- 32,681
- 5
- 61
- 85
-
1Checking request method and referrer will give you something like PostBack :) – dariol Jan 24 '10 at 20:09
0
Function IsPostBack()
IsPostBack = false
If Request.ServerVariables("REQUEST_METHOD") <> "POST" Then
Exit Function
End If
Dim referer: referer = Request.ServerVariables("HTTP_REFERER")
Dim current: current = Request.ServerVariables("HTTP_ORIGIN") & Request.ServerVariables("SCRIPT_NAME")
Dim i: i = InStr(1, referer, "?", 1)
If i > 1 Then
referer = Left(referer, i - 1)
End If
IsPostBack = LCase(current) = LCase(referer)
End Function

tb-mtg
- 529
- 8
- 10