Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > LOOP through an ASP form's pages (not ASP.NET - ASP classic)

Reply
Thread Tools

LOOP through an ASP form's pages (not ASP.NET - ASP classic)

 
 
David A. Beck
Guest
Posts: n/a
 
      04-12-2004
I found a great article and use the techniques to loop through a form and
get all the controls in ASP.NET "Looping Through Controls in ASP.NET"
http://www.extremeexperts.com/Net/Ar...hControls.aspx

I want to do the same thing in a VB COM control for classic ASP. Can anyone
point me to an article that shows me how to get the control type, etc?

Dab


 
Reply With Quote
 
 
 
 
David A. Beck
Guest
Posts: n/a
 
      04-12-2004
Curt,

In the COM object, using the scripting context, there is no .Items
collection in the Request Object.

Dab
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:(E-Mail Removed)...
> perhaps
>
> for each item in Reqest.Items
> response.write item & "=" & item.value
> next
>
>
> --
> Curt Christianson
> Owner/Lead Developer, DF-Software
> www.Darkfalz.com
>
>
> "David A. Beck" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I found a great article and use the techniques to loop through a form

and
> > get all the controls in ASP.NET "Looping Through Controls in ASP.NET"
> > http://www.extremeexperts.com/Net/Ar...hControls.aspx
> >
> > I want to do the same thing in a VB COM control for classic ASP. Can

> anyone
> > point me to an article that shows me how to get the control type, etc?
> >
> > Dab
> >
> >

>
>



 
Reply With Quote
 
 
 
 
Scott McNair
Guest
Posts: n/a
 
      04-12-2004
"David A. Beck" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> I found a great article and use the techniques to loop through a form
> and get all the controls in ASP.NET "Looping Through Controls in
> ASP.NET"
> http://www.extremeexperts.com/Net/Ar...hControls.aspx
>
> I want to do the same thing in a VB COM control for classic ASP. Can
> anyone point me to an article that shows me how to get the control
> type, etc?


If you're calling the form thru <form method=post>, it would be

For Each Item In Request.Form
Response.Write Item & ": " & Request(Item) & "<br>"
Next

If it's just a generic <form> object,

For Each Item In Request.QueryString
Response.Write Item & ": " & Request(Item) & "<br>"
Next
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      04-12-2004
Scott McNair wrote on 12 apr 2004 in
microsoft.public.inetserver.asp.general:
> For Each Item In Request.Form
> Response.Write Item & ": " & Request(Item) & "<br>"
> Next


This will not be correct if there is also a querystring

Use:

For Each Item In Request.Form
Response.Write Item & ": " & Request.Form(Item) & "<br>"
Next


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
David A. Beck
Guest
Posts: n/a
 
      04-12-2004
Scott:

Could you send a small page with this code in it, because I'm not getting
any joy using it in mime. Thanks.

Dab
"Scott McNair" <(E-Mail Removed)> wrote in message
news:Xns94C9967EEBEACsfmco@207.46.248.16...
> "David A. Beck" <(E-Mail Removed)> wrote in
> news:(E-Mail Removed):
>
> > I found a great article and use the techniques to loop through a form
> > and get all the controls in ASP.NET "Looping Through Controls in
> > ASP.NET"
> > http://www.extremeexperts.com/Net/Ar...hControls.aspx
> >
> > I want to do the same thing in a VB COM control for classic ASP. Can
> > anyone point me to an article that shows me how to get the control
> > type, etc?

>
> If you're calling the form thru <form method=post>, it would be
>
> For Each Item In Request.Form
> Response.Write Item & ": " & Request(Item) & "<br>"
> Next
>
> If it's just a generic <form> object,
>
> For Each Item In Request.QueryString
> Response.Write Item & ": " & Request(Item) & "<br>"
> Next



 
Reply With Quote
 
Scott McNair
Guest
Posts: n/a
 
      04-12-2004
"David A. Beck" <(E-Mail Removed)> wrote in news:u8XdHsMIEHA.2836
@TK2MSFTNGP11.phx.gbl:

> Scott:
>
> Could you send a small page with this code in it, because I'm not getting
> any joy using it in mime. Thanks.
>
> Dab


On it's way!

-Scott
 
Reply With Quote
 
[MSFT]
Guest
Posts: n/a
 
      04-13-2004
Hi David,

In ScriptingContext, IRequest interface also have FORM collection. You may
take a look at following MSDN articles:

Request.Form Collection
http://msdn.microsoft.com/library/de...us/iissdk/iis/
ref_vbom_reqocf.asp

Request Object
http://msdn.microsoft.com/library/de...us/iissdk/iis/
ref_vbom_reqo.asp?frame=true

IScriptingContext::get_Request
http://msdn.microsoft.com/library/de...us/iissdk/iis/
ref_biobj_cppiscget_rqst.asp

IScriptingContext C++ Interface
http://msdn.microsoft.com/library/de...us/iissdk/iis/
ref_biobj_cppisc.asp

Accessing ASP Built-In Objects from Components
http://msdn.microsoft.com/library/de...us/iissdk/iis/
accessingaspbuiltinobjectsfromcomponents.asp

In the post you sent in asp.components, I may misunderstand your
description. I think above information should be what you are looking for.
Hope them help.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

 
Reply With Quote
 
Scott McNair
Guest
Posts: n/a
 
      04-13-2004
Scott McNair <(E-Mail Removed)> wrote in
news:Xns94C9967EEBEACsfmco@207.46.248.16:

> If you're calling the form thru <form method=post>, it would be
>
> For Each Item In Request.Form
> Response.Write Item & ": " & Request(Item) & "<br>"
> Next
>
> If it's just a generic <form> object,
>
> For Each Item In Request.QueryString
> Response.Write Item & ": " & Request(Item) & "<br>"
> Next


Just as a side note, I've found this technique very useful for
populating a table on a database - as long as the field names in the
table are the same as the form object names, it's as easy as:

[set up your connection, recordset, etc]
RS.AddNew
For Each Item In Request.Form
RS(Item) = Request.Form(Item)
Next
RS.Update

I find it's a good way to populate a table with a kajillion different
fields from a table with a kajillion different fields, in essentially 3
lines of code.
 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      04-13-2004
Scott McNair wrote:
> Scott McNair <(E-Mail Removed)> wrote in
> news:Xns94C9967EEBEACsfmco@207.46.248.16:
>
> Just as a side note, I've found this technique very useful for
> populating a table on a database - as long as the field names in the
> table are the same as the form object names,


And the datatypes cooperate ....

> it's as easy as:
> [set up your connection, recordset, etc]
> RS.AddNew
> For Each Item In Request.Form
> RS(Item) = Request.Form(Item)
> Next
> RS.Update
>
> I find it's a good way to populate a table with a kajillion different
> fields from a table with a kajillion different fields, in essentially
> 3 lines of code.


It's great for the coder - not so good for the application performance and
scalability. Cursors should not be used for data maintenance. How about
this:

sSQLi = "INSERT INTO table ("
sSQLv = " VALUES("
for each Item In Request.Form
sSQLi = sSQLi & Item & ","
'you will need logic here to handle various datatypes
Select Case datatype
Case "Text"
sSQLv= sSQLv & "'" & Replace(Request.Form(Item),"'","''") & "',"
Case "Number"
sSQLv= sSQLv & Replace(Request.Form(Item),"'","''") & ","
Case "Date"
sSQLv= sSQLv & "#" & Replace(Request.Form(Item),"'","''") & "#,"
Next
'get rid of the trailing commas
sSQLi = Left(sSQLi,len(sSQLi) - 1) & ")"
sSQLv = Left(sSQLv,len(sSQLv)-1) & ")"
sSQL = sSQLi & sSQLv
Response.write sSQL
conn.Execute ,,129

Now you've had to write a little more code, but, now you've handled all the
chores that ADO needs to do behind the scenes anyways when updating a
recordset. Pluse you've eliminated the need to open an expensive updatable
cursor.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


 
Reply With Quote
 
Scott McNair
Guest
Posts: n/a
 
      04-13-2004
"Bob Barrows [MVP]" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> Now you've had to write a little more code, but, now you've handled
> all the chores that ADO needs to do behind the scenes anyways when
> updating a recordset. Pluse you've eliminated the need to open an
> expensive updatable cursor.


Good call.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Triple nested loop python (While loop insde of for loop inside ofwhile loop) Isaac Won Python 9 03-04-2013 10:08 AM
Re: How to loop through a list while inside the loop, the list size may be decreased? Roedy Green Java 3 09-13-2008 01:51 AM
Loop through a Plain Radio Button in ASP.NET Brian ASP .Net 33 02-25-2005 07:15 PM
Object with all of form's controls to loop through ASP.NET David A. Beck ASP .Net 4 11-18-2003 03:04 AM
Four ASP.NET Pages in Frames Vs. One ASP.NET Pages Manish ASP .Net 1 11-17-2003 05:56 PM



Advertisments