call post w/ classic asp

I've got a form that posts to itself when submitted.

Right now, after the form is submitted, the code checks that all of its
fields are valid, then processes the information. If all goes well, visitors
are then redirected using Response.Redirect("thanks.asp").

What I'd like to do is replace Response.Redirect("thanks.asp") with
something more like the post that happens on the form so that "thanks.asp"
can display a summary of what was submitted.

Is there a way to do this? Can you call a "post" somehow from Classic ASP?

I have not spent a lot of time with ASP, so it could be something simple!
jp2code [ Mi, 19 September 2007 14:53 ] [ ID #1824236 ]

Re: call post w/ classic asp

"jp2code" <poojo.com/mail> wrote:

>I've got a form that posts to itself when submitted.
>
>Right now, after the form is submitted, the code checks that all of its
>fields are valid, then processes the information. If all goes well, visitors
>are then redirected using Response.Redirect("thanks.asp").
>
>What I'd like to do is replace Response.Redirect("thanks.asp") with
>something more like the post that happens on the form so that "thanks.asp"
>can display a summary of what was submitted.
>
>Is there a way to do this? Can you call a "post" somehow from Classic ASP?

No. IMHO the best way to handle this is to store the data from the
form into the session object (Session("myvar")=whatever). Then the
page you forward to can retrieve the data from there and do whatever
it wants with it.

--
Tim Slattery
MS MVP(DTS)
Slattery_T [at] bls.gov
http://members.cox.net/slatteryt
Tim Slattery [ Mi, 19 September 2007 14:59 ] [ ID #1824237 ]

Re: call post w/ classic asp

"jp2code" <poojo.com/mail> wrote in message
news:%23eVvUwr%23HHA.748 [at] TK2MSFTNGP04.phx.gbl...
> I've got a form that posts to itself when submitted.
>
> Right now, after the form is submitted, the code checks that all of its
> fields are valid, then processes the information. If all goes well,
> visitors are then redirected using Response.Redirect("thanks.asp").
>
> What I'd like to do is replace Response.Redirect("thanks.asp") with
> something more like the post that happens on the form so that "thanks.asp"
> can display a summary of what was submitted.
>
> Is there a way to do this? Can you call a "post" somehow from Classic ASP?
>

Instead of Response.Redirect, use Response.Write to summarise what was
submitted. Yes, it really is that simple.

<%
Sub showform
%>
<form method="post">
Your Name: <input type="text" name="FirstName" />

<input type="submit" name="Submit" value="Submit" />
</form>
<%
End Sub

If Request.Form("Submit") = "" Then
call showform()
Else
If Len(Trim(Request.Form("FirstName")))>0 Then
Response.Write "Your name is " & Trim(Request.Form("FirstName"))
Response.Write "
Thanks!!"
Else
Response.Write "You forgot to enter your name"
call showform()
End If
End If
%>

--
Mike Brind
Mike Brind [ Mi, 19 September 2007 15:18 ] [ ID #1824238 ]

Re: call post w/ classic asp

"Mike Brind" <dummy [at] newsgroups.com> wrote in message
news:u7Iqg%23r%23HHA.5164 [at] TK2MSFTNGP05.phx.gbl...
>
> "jp2code" <poojo.com/mail> wrote in message
> news:%23eVvUwr%23HHA.748 [at] TK2MSFTNGP04.phx.gbl...
>> I've got a form that posts to itself when submitted.
>>
>> Right now, after the form is submitted, the code checks that all of its
>> fields are valid, then processes the information. If all goes well,
>> visitors are then redirected using Response.Redirect("thanks.asp").
>>
>> What I'd like to do is replace Response.Redirect("thanks.asp") with
>> something more like the post that happens on the form so that
>> "thanks.asp" can display a summary of what was submitted.
>>
>> Is there a way to do this? Can you call a "post" somehow from Classic
>> ASP?
>>
>
> Instead of Response.Redirect, use Response.Write to summarise what was
> submitted. Yes, it really is that simple.
>
> <%
> Sub showform
> %>
> <form method="post">
> Your Name: <input type="text" name="FirstName" />

> <input type="submit" name="Submit" value="Submit" />
> </form>
> <%
> End Sub
>
> If Request.Form("Submit") = "" Then
> call showform()
> Else
> If Len(Trim(Request.Form("FirstName")))>0 Then
> Response.Write "Your name is " & Trim(Request.Form("FirstName"))
> Response.Write "
Thanks!!"
> Else
> Response.Write "You forgot to enter your name"
> call showform()
> End If
> End If
> %>
>

By the way, if you really do want to bounce visitors from one page to the
next, a simple way to expidite Tim's suggestions is as follows:

For Each x in Request.Form
If x <> "Submit" then Session(x) = Request.Form(x)
Next
Response.Redirect "thanks.asp"

You should also be aware that there is no way to guarantee the order in
which the Request.Form collection contents are passed.

--
Mike Brind
Mike Brind [ Mi, 19 September 2007 15:33 ] [ ID #1824239 ]

Re: call post w/ classic asp

Wow! That's something slick I probably would not have thought of!

Thanks Mr. Brind!

"Mike Brind" suggests:
>
> By the way, if you really do want to bounce visitors from one page to the
> next, a simple way to expidite Tim's suggestions is as follows:
>
> For Each x in Request.Form
> If x <> "Submit" then Session(x) = Request.Form(x)
> Next
> Response.Redirect "thanks.asp"
>
> You should also be aware that there is no way to guarantee the order in
> which the Request.Form collection contents are passed.
>
> --
> Mike Brind
>
jp2code [ Mi, 19 September 2007 15:49 ] [ ID #1824240 ]

Re: call post w/ classic asp

Mr. Slattery:

Thanks! That was even easy to implement! I've already got it working.

A+

"Tim Slattery" wrote:
>
> No. IMHO the best way to handle this is to store the data from the
> form into the session object (Session("myvar")=whatever). Then the
> page you forward to can retrieve the data from there and do whatever
> it wants with it.
>
> --
> Tim Slattery
> MS MVP(DTS)
> Slattery_T [at] bls.gov
> http://members.cox.net/slatteryt
jp2code [ Mi, 19 September 2007 15:50 ] [ ID #1824241 ]

Re: call post w/ classic asp

instead of redirecting, you can use "server.execute". When you need to process that code, use :

server.execute("thanks.asp")

the "thanks.asp" file will have use of all information in the request object.


"jp2code" <poojo.com/mail> wrote in message news:%23eVvUwr%23HHA.748 [at] TK2MSFTNGP04.phx.gbl...
> I've got a form that posts to itself when submitted.
>
> Right now, after the form is submitted, the code checks that all of its fields are valid, then processes the information. If all
> goes well, visitors are then redirected using Response.Redirect("thanks.asp").
>
> What I'd like to do is replace Response.Redirect("thanks.asp") with something more like the post that happens on the form so that
> "thanks.asp" can display a summary of what was submitted.
>
> Is there a way to do this? Can you call a "post" somehow from Classic ASP?
>
> I have not spent a lot of time with ASP, so it could be something simple!
>
Jon Paal [ Mi, 19 September 2007 17:59 ] [ ID #1824242 ]

Re: call post w/ classic asp

So, lots of different tricks for doing the same thing! I like it!

"Jon Paal [MSMD]" pointed out:
> instead of redirecting, you can use "server.execute". When you need to
> process that code, use :
>
> server.execute("thanks.asp")
>
> the "thanks.asp" file will have use of all information in the request
> object.
>
jp2code [ Mi, 19 September 2007 18:12 ] [ ID #1824243 ]

Re: call post w/ classic asp

"jp2code" wrote:
> So, lots of different tricks for doing the same thing! I like it!

Can you stand another? There is also Server.Transfer:
http://msdn2.microsoft.com/en-us/library/ms525800.aspx



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Dave Anderson [ Mi, 19 September 2007 18:22 ] [ ID #1824244 ]

Re: call post w/ classic asp

"jp2code" <poojo.com/mail> wrote in message
news:ex9IwPs%23HHA.3548 [at] TK2MSFTNGP06.phx.gbl...
> "Mike Brind" suggests:
> >
> > By the way, if you really do want to bounce visitors from one page to
the
> > next, a simple way to expidite Tim's suggestions is as follows:
> >
> > For Each x in Request.Form
> > If x <> "Submit" then Session(x) = Request.Form(x)
> > Next
> > Response.Redirect "thanks.asp"
> >
> > You should also be aware that there is no way to guarantee the order in
> > which the Request.Form collection contents are passed.
> >
> > --
> > Mike Brind
> >
>
> Wow! That's something slick I probably would not have thought of!
>
> Thanks Mr. Brind!
>

The problem with this approach is you pollute the Session object, which is
common to all pages for that session, with internal details regarding a
specific page. This is not a good thing. Consider what would happen if
such a form happened use a field name that matches an existing session
variable being used for a complete different purpose.

Use Server.Execute as suggested by Jon Paal, whist there are many solutions
to your requirement Server.Execute is the most appropriate.

--
Anthony Jones - MVP ASP/ASP.NET
Anthony Jones [ Do, 20 September 2007 09:31 ] [ ID #1825211 ]

Re: call post w/ classic asp

Gazing into my crystal ball I observed "jp2code" <poojo.com/mail>
writing in news:#eVvUwr#HHA.748 [at] TK2MSFTNGP04.phx.gbl:

> I've got a form that posts to itself when submitted.
>
> Right now, after the form is submitted, the code checks that all of
> its fields are valid, then processes the information. If all goes
> well, visitors are then redirected using
> Response.Redirect("thanks.asp").
>
> What I'd like to do is replace Response.Redirect("thanks.asp") with
> something more like the post that happens on the form so that
> "thanks.asp" can display a summary of what was submitted.
>
> Is there a way to do this? Can you call a "post" somehow from Classic
> ASP?
>
> I have not spent a lot of time with ASP, so it could be something
> simple!
>
>

The way I deal with this is this:
1. Start the page off with issubmitted = false
2. Validate and do whatever posting to db I need to do.
3. Change issubmitted to true

HTML is something like:
<% if not issubmitted then%>
<form method="post" action="<%=request.servervariables("Script_name")%>">
<div>
<label for="name" id="name1">Name:</label> <input type="text" name="name"
value="<%=name%>" id="name"><br>
<input type="submit" value="Submit">
</form>
<%else%>
<p>Thank you for submitting the information below:</p>
<dl>
<%For ix = 1 to Request.Form.Count
field = request.form.key(ix)
inputvalue = request.form.item(ix)%>
<dt><%=field%></dt>
<dd><%=inputvalue%></dd>
<%next%>
</dl>
<%end if%>

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share
Adrienne Boswell [ Fr, 21 September 2007 05:31 ] [ ID #1826257 ]
Webserver » microsoft.public.inetserver.asp.general » call post w/ classic asp

Vorheriges Thema: loosing page breaks
Nächstes Thema: Session variable, security, SSL, I'm confused