Very Basic Question

J

James Baker

I'm getting a QueryString on a page. From this query string, I need to
query a database, get a bunch of file names, attach them to an e-mail and
fire it out (no problem). The problem is, I want it to happen when a user
clicks a button.

I've been using .NET for so long (this isn't a problem at all in .NET
obviously)...that I've forgotten how to handle this. Am I going to need a
second page to post an array of the file names to and then handle it there?
It just seems awfully redundant to need a second page to handle all of this,
but I guess it wouldn't shock me. It's been years since I've used classic
ASP, so bear with me =).
 
M

Manohar Kamath [MVP]

You can post the page to itself (default behaviour, if you don't specify the
second page). You need to set a hidden variable so you know if you are
entering the page the first time, or if it is a postback. Sorry, classic ASP
does not support isPostBack :)
 
J

James Baker

I'm creating a bunch of hidden values for each file that needs to be loaded.
If I set the target to itself (I assume via action='self.asp'), how do I
determine if it's a postback? Just do a Request.Form of the hidden values
and make sure to make them distinct from any values I had on the previous
form? I figure I just answered my own question, but just making sure I have
the concept right before I charge forward on this.

Thanks!
James
 
J

James Baker

You have no idea how many times I've tried to type that =). Using entirely
wrong syntax for VBScript too. Every page I've typed:

if (!IsPostBack)

and then hit backspace 15 times. I'll re-get the hang of it I suppose.

But you're saying that if I have no "action" attribute of my form, it will
default to posting to itself?

Thanks,
James
 
M

Manohar Kamath [MVP]

That's correct... leaving action attribute empty lets the page post to
itself.
 
P

Paul Baker [MVP, Windows - SDK]

Rather than checking for hidden values, you could check the HTTP verb to see
if it is a postback or not. If it is POST, it is. If it is GET, it isn't.
You can use Request.ServerVariables("REQUEST_METHOD").

Paul
 
D

David C. Holley

Well, the second page does allow you to provide a confirmation that the
process succeeded. So don't think of it as a second page, but rather as
a confirmation and of course you can setup things up so that if the
second page fails, an error page is presented instead of a confirmation.

David C. Holley
www.gatewayorlando.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top