473,842 Members | 1,382 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form Field Type

Hello Friends

I have written a simple HTML page in aspx
I have added form elements like "textBox", "Hidden fields", "images", "radio buttons" to the html form

I am posting the data back to the same page
Is there a way to know the "Type" of a form element upon post back. Meaning in the code behind file of the page, is there a way to find the "Type" all the form elements ("textBox", "Hidden fields", "images", "radio buttons" etc

Any guidance will be greatly appreciated

Many Thanks
Mohit
Nov 18 '05 #1
10 1901
I'm not quite sure what you're trying to do - do you want to be able to find
out the types because you are planning to have some page for which you don't
know the controls in advance?

All controls ("form elements" as you call them) which are set with the
attribute "runat=serv er" will appear in the Page's Controls collection (of
type ControlCollecti on). You can loop through this collection and use
GetType() on each control to give you the type of the control (it gives you
a Type object, but you can use ToString() on this to get a string with the
name of the type). This only applies to those which you have set with the
attribute above - any HTML controls which you add for which you don't add
this attribute won't be in the Controls collection.

Does that help at all? -is that the kind of thing you want to do?

Pete Beech
"Mohit Gupta" <mb*******@yaho o.com> wrote in message
news:E1******** *************** ***********@mic rosoft.com...
Hello Friends,

I have written a simple HTML page in aspx.
I have added form elements like "textBox", "Hidden fields", "images", "radio buttons" to the html form.
I am posting the data back to the same page.
Is there a way to know the "Type" of a form element upon post back. Meaning in the code behind file of the page, is there a way to find the
"Type" all the form elements ("textBox", "Hidden fields", "images", "radio
buttons" etc)
Any guidance will be greatly appreciated.

Many Thanks,
Mohit

Nov 18 '05 #2
I'm not quite sure what you're trying to do - do you want to be able to find
out the types because you are planning to have some page for which you don't
know the controls in advance?

All controls ("form elements" as you call them) which are set with the
attribute "runat=serv er" will appear in the Page's Controls collection (of
type ControlCollecti on). You can loop through this collection and use
GetType() on each control to give you the type of the control (it gives you
a Type object, but you can use ToString() on this to get a string with the
name of the type). This only applies to those which you have set with the
attribute above - any HTML controls which you add for which you don't add
this attribute won't be in the Controls collection.

Does that help at all? -is that the kind of thing you want to do?

Pete Beech
"Mohit Gupta" <mb*******@yaho o.com> wrote in message
news:E1******** *************** ***********@mic rosoft.com...
Hello Friends,

I have written a simple HTML page in aspx.
I have added form elements like "textBox", "Hidden fields", "images", "radio buttons" to the html form.
I am posting the data back to the same page.
Is there a way to know the "Type" of a form element upon post back. Meaning in the code behind file of the page, is there a way to find the
"Type" all the form elements ("textBox", "Hidden fields", "images", "radio
buttons" etc)
Any guidance will be greatly appreciated.

Many Thanks,
Mohit

Nov 18 '05 #3
Thanks for your reply Pete

Actually this is not what i am looking for
The controls are not server side controls, they are plain HTML 4.0 controls. So i cannot use the controlCollecti on
Is there a way to get the type of HTML 4.0 elements (<input type=hidden name=mycontrol> ...)?

Thank You

Mohit
Nov 18 '05 #4
Thanks for your reply Pete

Actually this is not what i am looking for
The controls are not server side controls, they are plain HTML 4.0 controls. So i cannot use the controlCollecti on
Is there a way to get the type of HTML 4.0 elements (<input type=hidden name=mycontrol> ...)?

Thank You

Mohit
Nov 18 '05 #5
No. In a POST Request, the form fields are represented by their names and
their values. Only.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Mohit Gupta" <an*******@disc ussions.microso ft.com> wrote in message
news:C1******** *************** ***********@mic rosoft.com...
Thanks for your reply Pete!

Actually this is not what i am looking for.
The controls are not server side controls, they are plain HTML 4.0 controls. So i cannot use the controlCollecti on. Is there a way to get the type of HTML 4.0 elements (<input type=hidden name=mycontrol> ...)??
Thank You.

Mohit

Nov 18 '05 #6
No. In a POST Request, the form fields are represented by their names and
their values. Only.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Mohit Gupta" <an*******@disc ussions.microso ft.com> wrote in message
news:C1******** *************** ***********@mic rosoft.com...
Thanks for your reply Pete!

Actually this is not what i am looking for.
The controls are not server side controls, they are plain HTML 4.0 controls. So i cannot use the controlCollecti on. Is there a way to get the type of HTML 4.0 elements (<input type=hidden name=mycontrol> ...)??
Thank You.

Mohit

Nov 18 '05 #7
The answer to your question is: No. The posting of form data is a HTTP
specification and it supplies you with the name-value pairings when a HTTP
Request of type post is initiated.

You could prefix your controls with some meaningful naming convention, i.e.
"txt" for text inputs, "ddl" for pull down menus (selects), etc. and then
iterate through the ASP.NET Request/form collection.

Like the 1st reply-er mentioned, it is not clear why you would need to go
through all this trouble to begin with other than raising the suspicion of
one asking for help on how to hack a website. I'm sure that's not the case,
but you still did not address such in your follow-up reply.

--
Peter O'Reilly
Nov 18 '05 #8
The answer to your question is: No. The posting of form data is a HTTP
specification and it supplies you with the name-value pairings when a HTTP
Request of type post is initiated.

You could prefix your controls with some meaningful naming convention, i.e.
"txt" for text inputs, "ddl" for pull down menus (selects), etc. and then
iterate through the ASP.NET Request/form collection.

Like the 1st reply-er mentioned, it is not clear why you would need to go
through all this trouble to begin with other than raising the suspicion of
one asking for help on how to hack a website. I'm sure that's not the case,
but you still did not address such in your follow-up reply.

--
Peter O'Reilly
Nov 18 '05 #9
You could make your plain HTML controls run on the server as well, by
including the runat=server attribute for each one - I guess they will still
be added to the Controls collection, though I've never tested that - I don't
think HTML Server Controls will behave differently to Web controls with
respect to being in the Controls collection (You can see the Control
collection by turning tracing on for the page, so you could very quickly
test this). Is that a possibility?

Otherwise, you can probably iterate through all the elements in your <form>
using javascript and the DOM (I don't know so much about javascript) - I'm
not quite sure what the best way would be to get that info to the server
though, which is where I presume you need it.

Cheers,
Pete Beech

"Mohit Gupta" <an*******@disc ussions.microso ft.com> wrote in message
news:C1******** *************** ***********@mic rosoft.com...
Thanks for your reply Pete!

Actually this is not what i am looking for.
The controls are not server side controls, they are plain HTML 4.0 controls. So i cannot use the controlCollecti on. Is there a way to get the type of HTML 4.0 elements (<input type=hidden name=mycontrol> ...)??
Thank You.

Mohit

Nov 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
2317
by: szar | last post by:
I'm passing numerous array elements called list when a form is submitted. the brackets are necessary for PHP to see all the values as an array. The problem is I can't seem to reference the form elements from javascripts because of the brackets. For example, form.list.value is no good. Anyone know a way around this? Thanks.
1
1986
by: Don Stefani | last post by:
Hello, I have a form that I want to submit "onchange", OK I've got that working, but when the form submits, I want to pass along a value to a CGI script, as if that value was in a hidden form element. BUT, I don't want that value to be in the actual HTML form, I want it to be created in my submit function. For instance:
6
9643
by: WindAndWaves | last post by:
Hi Gurus In my quest in putting my first javascript together, I am now trying to conquer something that seems trivial, but has taken me hours. I would like to format a field in a form once the person has completed it. The format should be "00". For example, if the person puts 1 then it should become 01 and if the person puts 12 in the field then it should stay like that. If the person puts 2004 then it should become 04, and if the...
3
4994
by: Steve | last post by:
Form FrmRestock's recordsource is QryFrmRestock. The TransactionDate field's criteria is set ats: Forms!FrmRestock!LastXDays. LastXDays on the form is a combobox where the selections are 30, 60 and 90. The default is set at 30. Question1: When the form opens, there are no records displayed although there are many records that fit the criteria of 30. If I put a button on the form to do a requery and press the button, all the records...
4
4193
by: GTi | last post by:
Is it possible to have a generic script that set the input focus on the first valid element in a document (not hidden or disabled) ? This script is at the end of a document, but don't work. <script type="text/javascript"> document.forms.elements.focus(); </script>
9
4185
by: julie.siebel | last post by:
Hello all! As embarrassing as it is to admit this, I've been designing db driven websites using javascript and vbscript for about 6-7 years now, and I am *horrible* at form validation. To be honest I usually hire someone to do it for me, grab predone scripts and kind of hack out the parts that I need, or just do very minimal validation (e.g. this is numeric, this is alpha-numeric, etc.)
6
1914
by: drec | last post by:
I am just learning Javascript and I would like to create a basic form that gives me two options. This will be using either checkbox or radio input type, however I would like the second option to allow the user to type in a value. Also, I would like the 2nd option only editable if the button for that option is selected. All I can seem to find is basic examples of forms, and none of which have this feature. The form would look something...
2
1950
by: Cerebral Believer | last post by:
Hi folks, Can anyone help me with this form: http://futurebydesign-music.com/_member/club_fbd_reg.php I have followed to coding instructions aas closely as I can, but I am getting errors about not filling in all the fields on the form correctly when I test it. Is validating a form with radio buttons difficult?
8
6705
by: M.L. | last post by:
Hello. I created a form using JS validation with the form tag as follows: <form name="form1" action="dynaform.php" method="post" onsubmit="return pvg_sub();"> The js validation script sends alerts when fields are not entered properly and it seems to work, except...when there are no errors, instead executing the php action script, I get a popup dialog box in IE6 asking if I want to download or run the php script. Can anyone tell me
2
1933
by: sbettadpur | last post by:
Hi everybody, Hi iam strugling with more than one submit buttons with in one form here is my code <form method="post" action="Offer.php" name='issueFrm' onSubmit="return fullOfferfields();"> OFFER <input type=image src="amarok_rewind.png " title="rewind" > <input type=image src="amarok_back.png" title="back"> <input type="text" size=3 name='txt'>&nbsp;<input type=image src="amarok_next.png " title="next" >&nbsp;<input type=image...
0
9717
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10618
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10683
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10320
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9459
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7862
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5699
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4096
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3148
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.