Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GET and POST - Probably Simple 8

Status
Not open for further replies.

Deadline

Programmer
Feb 28, 2001
367
0
0
US
Get And Post

Hi,

Can I use Request.Form("you") and Request.QueryString("yourself") in the Same ASP page ?

I mean, can I refer this particular ASP page using GET method in some HTML file and POST method in some other HTML file ?

Hope this is a genuine doubt.



Thanks in advance.

RR.

 
Hi,

I don't think this is possible, because the way to submit the form is either post or get. I will suggest you to store the query string into hidden field and use 'post' method to submit the data, this way you can carry all the data you need to the next page.

Hope this helps Chiu Chan
cchan@emagine-solutions.com
 
Hi Chan,

Thank you very much for responding. But I guess you haven't Got my question correctly yet. Let me explain.


Let us say we have ArrowA.ASP, ArrowB.ASP and Target.ASP

Now I need to refer Target.ASP on Submission of ArrowA.ASP as well as ArrowB.ASP

My question is whether I can use GET in ArrowA.ASP and POST in ArrowB.ASP - both apparently to referring to Target.ASP.

Thanks again.

RR.








 
My suggestion would be to do this:

put a hidden field on both targetA and targetB that denote what page it is:

<input type=hidden name=originationPage value=targeta>
on targetA.asp

and

<input type=hidden name=originationPage value=targetb>
on targetB.asp

Then, you would write two separate subroutines on target.asp which would handle either one:

dim originationPage
originationPage = request(&quot;originationPage&quot;)

Generally, it's not good to not specify which you are going to use... i.e. request.form or request.querystring, but in this case, you could then just call subA or subB to handle the different cases, and since you are only making the one unqualified call, I think your performance could take the tiny hit...

if originationPage = &quot;targeta&quot; then
'call subA to do targetA stuff
else
'call subB to do targetB stuff
end if

Then, obviously, subA would have the .form methods in it, and subB would have the .querystring methods in it...

hope it helps! :)
Paul Prewett
 
Thank you very much Paul. That helped a bit.

Out of curiousity, what will happen if I just use straight away Request.QueryString and Request.Form() without identifying the sources ?

Thanks in advance.

RR.
 
That's a good question. I couldn't tell you what will happen, but I could tell you how to find out. ;-)

 
There is no reason that you can't have ArrowA post to Target.asp and ArrowB Get to Target.asp. Just code Target.asp to check the Querystring and if the value of the item is there, process it. If the querystring isn't there, but the form fields are, process those.
 
other way to do is:

If Request.ServerVariables(&quot;REQUEST_METHOD&quot;) = &quot;POST&quot; Then
variableX = Request.Form(&quot;X&quot;)
Else
variableX = Request.QueryString(&quot;X&quot;)
End If

festivista97,
if the form uses &quot;POST&quot; and you use QueryString in Target.asp then you cannot get the value of the parameter.
 
For argument's sake: I know it's bad form, and you'll take a minor performance hit, but why not just evaluate Request(&quot;x&quot;), without specifying the method? I believe IIS will look in .querystring first, then .form, (or vice versa, I forget which) until it finds the item.
 
Thank you all of you guys.. That was a real brainstorming session I had.. Thank you...
RR

 
FYI if you're interested, I have used both in the same page from the same form with no problem. For example:

source.asp:

<FORM name=&quot;myForm&quot; action=&quot;target.asp?action=1&otherVar=<%=MyVar%>&quot; method=&quot;POST&quot;>
...
</FORM>


target.asp:

<%


MyForm = Request.Form
MyQueryStr = Request.QueryString

...

%>


 

DesperateCoder,

Yes you can do request.form and request.querystring to the same asp page. By default, I use request.form for submit buttons and if there is an exception, I can call a javascript function to use to the same ASP page:

document.location=&quot;next.asp?var1=&quot; + txt1


fengshui1998
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top