Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 7th, 2004, 03:50 PM
Registered User
 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default finding control type

Hi,
I am trying to find control type dyanamically in asp like whether it is textbox or a button,please help me out this

 
Old June 7th, 2004, 09:56 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

AFAIK, finding the control type in ASP doesn't seem possible, as on submission of form, anyone would look for the values that come from the controls and never mind what control it is.

Be it any type, just a REQUEST.FORM("CONTROLNAME") --> VALUE of the form CONTROL.

May be you are the first in my knowledge to have asked about finding its type. I am sure we will find a way to help you out. But, can you explain us on what you are trying to accomplish, so as to help you in a better way.

Cheers!

_________________________
-Vijay G
Strive for Perfection
 
Old June 8th, 2004, 02:17 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Vijay is right. In "classic" ASP, there is no way of find out the type. All the values for the controls are just added to the Request.Form or Request.QueryString collections.

What you could do is stick to a strict naming scheme. For example, I always prefix my controls with three letters: txt for text boxes, lst for <select> list, chk for check boxes etc.
Using such a scheme, you could check for the first three characters of each control name to determine its type.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old June 8th, 2004, 04:35 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yes, IMAR is right. That way u can find it is textbox or other

 
Old June 16th, 2004, 02:54 PM
Registered User
 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your help.The situation is like this.There are total 4 asp pages and out of that 3 asp pages submitting their data to one common asp page,all the control names on 3 asp pages are different and they did not follwoed any coding standards(this is someone's old code).After submitting the data on 4 th asp page I have to collect all the data(except hidden,buttons) and I need to send an eamil to customer.So I am trying to find a short cut answer by looping form collecton by making if condition on control type instead of accesing each control individually.Any help is appriciated

 
Old June 16th, 2004, 03:34 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi there,

All I could think now is that, you got to change the name of the CONTROLs to be prefixed with txt(textbox) or chk(Checkbox) or opt(Radio button) or lst(List box) etc... in those three pages as Imar had suggested. And on the 4th based on the first three prefix values you can take its values and proceed next. This you could do only if you still want to know its control types.

Else just by giving a Request.Form("ControlName") in any case would give the value associated with it. So I dont think you would be facing more problem in extracting the data and sending it out as email.

Or by using Form collection object, if you are looking for specific control names and its values for sending out email, then you can always use like this. Copy paste the following code and test that out to get a better picture.

Code:
<% if request.form("Submit") <>"" then
    For Each x In Request.Form %>
        <%= x %> = <%= Request.Form(x) %> <BR>
    <% Next %>
<%End If %>

<html>
<FORM ACTION = "" METHOD = "post">
   <P>Your first name: <INPUT NAME = "firstname" SIZE = 48>
   <P>What is your favorite ice cream flavor: <SELECT NAME = "flavor">
   <OPTION>Vanilla
   <OPTION>Strawberry
   <OPTION>Chocolate
   <OPTION>Rocky Road</SELECT>
   <p><INPUT name="submit" TYPE = SUBMIT value="submit">
</FORM>
</html>
You can take a look at these pages to see how the REQUEST.FORM is used and FORM collection is used. That should help you in a way.

ASP Request Object Form Collection

The Form Collection

Hope that helps.
Cheers!

_________________________
-Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding items in a dropdownlist control johnnycorpse Classic ASP Components 0 May 18th, 2007 04:09 AM
Convert "String" type to "Control" type ? kishore_peddi C# 4 January 11th, 2006 01:21 PM
Finding Field Type & string length From dataset? Jackie VB.NET 2002/2003 Basics 4 July 9th, 2003 04:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.