INTELLIGENT WORK FORUMS FOR COMPUTER PROFESSIONALS
Come Join Us!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts
- Keyword Search
- Turn Off Ad Banners
- One-Click Access To Your
Favorite Forums
- Automated Signatures
On Your Posts
- Best Of All, It's Free!
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Partner With Us!
"Best Of Breed" Forums Add Stickiness To Your Site

(Download This Button Today!)
Member Feedback
"...Keep up the good work - excellent site - i'd been looking for something like this for ages !..."
Geography
Where in the world do Tek-Tips members come from?
|
Microsoft: Active Server Pages (ASP) FAQ
|
ASP 101
|
How can I update the server and reload a page preserving QueryString data?
Posted: 24 Aug 04
|
Picture this: Your user is on a page and they want to select something that will force a change in a setting you have on your ASP objects, such as a variable in a COM object or whatever. Ignoring possible methods using cookies or go.back, this is one way it can be updated and put the user back on the page he was at with the QueryString data preserved. (As I said, there surely are other ways, but this one works and demonstrates how to pick up and recycle the QueryString data.)
Typically, GET/QueryString data is used to set up a page while POST/Form data is used for data submission. Since that's not always the case, you have to be sure that re-creating your GETs won't do someing unwanted such as duplicating one-time writes or requests, etc.
CODE<% Dim xPass, xPassTmp, in_PassItem, curQString curQString = "" in_PassItem = "0" If session("ee_data") <> "" Then If Request.ServerVariables("REQUEST_METHOD")="GET" Then xPass = False ' flag for valid changes ' check for special server-side update xPassTmp = Request.QueryString("serversidevar") ' this example will filter for valid entry request, such as a number 1 to 5 If varType(xPassTmp) = 8 and len(xPassTmp) = 1 Then If inStr("12345",xPassTmp) > 0 Then session("myObj").aspPassItem = xPassTmp xPass = True End If End If If xPass Then ' Redirection to this page again is done since a user selecting a page ' (not Pass case) might interfere with some pages which call themselves ' with and without passing URL variables. ' Only GET (QueryString) is resent, not POST (Form). If len(request.QueryString("passqs")) > 0 Then curQString = "?" & request.QueryString("passqs") End If response.redirect "https://" & request.ServerVariables("server_name") & request.ServerVariables("URL") & curQString End If End If ' this next code executes only if this is a standard querystring entry in_PassItem = session("myObj").aspPassItem If len(request.ServerVariables("query_string")) > 0 Then curQString = "&passqs=" & server.URLEncode(request.ServerVariables("query_string")) ' in case new setting selected End If End If %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>Test: update server and return to QueryString page</TITLE> </HEAD> <BODY> <a id="RequestLink_1" href="<%=request.ServerVariables("URL")%>?serversidevar="1"<%=CurQString%>">Click here to change something on the server side</a></TD> </BODY> </HTML> dbMark |
Back to Microsoft: Active Server Pages (ASP) FAQ Index
Back to Microsoft: Active Server Pages (ASP) Forum
My FAQ Archive
Email This FAQ To A Friend |
|
 |
|