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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check all controls on page 2

Status
Not open for further replies.

rtshort

IS-IT--Management
Feb 28, 2001
878
0
0
US
Is there a way to check all of the controls on an asp page at once like you can do in VB. Like:

Code:
For each ctl in controls


Rob
Just my $.02.
 
Yes.

Dim Control
For each Control in Request.Form

Next
 
cool... so simple...
Kendel, I was just about to ask this same question, and you answered it before I could ask!

Earnie Eng
 
There's you another Star Kendell. Would you elaborate a little further though.

Does Request.Form work for that form, or does it need to be Request.FormName? Also, could that go into a Public Function, like CheckControls and then called when needed?

Thanks a million.

Rob
Just my $.02.
 
Request.Form is all that is necessary.
You need to put the for loop in a page that the form submits to. For example this is a dumbed down version of what I used the code for... I had too many controls, and did not want to re-type them again when processing the info in ASP. So I made the code spit out the name of the fields(so I can copy/paste) as well as the data(just for error checking):

--- form.asp ---
Code:
<form action=&quot;processForm.asp&quot; method=&quot;post&quot; enctype=... etc.>
.
. put for form controls here
.

--- processForm.asp ---
Code:
. insert your html headers and whatnot here...
.
.
<%
  for each frmItem in request.form
    response.write(frmItem & &quot;: &quot; & request.form(frmItem) & &quot;<br>&quot;)
  next
%>
.
.
.

in the line
Code:
response.write(
Code:
frmItem
Code:
 & &quot;: &quot; &
Code:
request.form(frmItem)
Code:
 & &quot;<br&quot;>)
:

Code:
frmItem
will output the name of the form control
Code:
request.form(frmItem)
will output the value stored in that form control

Earnie Eng
 
rtshort, didn't see your post. Did ahmun answer your question?

Request.Form is all you need.

You can have the CheckControl in 1 asp page.

-----functions.asp------
Public Function CheckControl
Dim Ctr
For Each Ctr in Request.Form
Response.Write Ctr & &quot;<br>&quot;
Next
End Function
--------------------------

And call it from your page

----your.asp--------
<!--#include file=&quot;functions.asp&quot;-->

Call CheckControl
--------------------------------
 
Thanks again Kendal. That clarifies it a little more for me. I was really wondering just that, if it could be used in an inclued file.

Thanks again.

Rob
Just my $.02.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top