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 10 1776
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=server" will appear in the Page's Controls collection (of
type ControlCollection). 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*******@yahoo.com> wrote in message
news:E1**********************************@microsof t.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
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=server" will appear in the Page's Controls collection (of
type ControlCollection). 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*******@yahoo.com> wrote in message
news:E1**********************************@microsof t.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
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 controlCollection
Is there a way to get the type of HTML 4.0 elements (<input type=hidden name=mycontrol> ...)?
Thank You
Mohit
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 controlCollection
Is there a way to get the type of HTML 4.0 elements (<input type=hidden name=mycontrol> ...)?
Thank You
Mohit
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*******@discussions.microsoft.com> wrote in message
news:C1**********************************@microsof t.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 controlCollection. Is there a way to get the type of HTML 4.0 elements (<input type=hidden
name=mycontrol> ...)?? Thank You.
Mohit
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*******@discussions.microsoft.com> wrote in message
news:C1**********************************@microsof t.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 controlCollection. Is there a way to get the type of HTML 4.0 elements (<input type=hidden
name=mycontrol> ...)?? Thank You.
Mohit
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
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
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*******@discussions.microsoft.com> wrote in message
news:C1**********************************@microsof t.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 controlCollection. Is there a way to get the type of HTML 4.0 elements (<input type=hidden
name=mycontrol> ...)?? Thank You.
Mohit
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*******@discussions.microsoft.com> wrote in message
news:C1**********************************@microsof t.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 controlCollection. Is there a way to get the type of HTML 4.0 elements (<input type=hidden
name=mycontrol> ...)?? Thank You.
Mohit This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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.
...
|
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...
|
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...
|
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...
|
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...
|
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();">...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
|
by: Johno34 |
last post by:
I have this click event on my form. It speaks to a Datasheet Subform
Private Sub Command260_Click()
Dim r As DAO.Recordset
Set r = Form_frmABCD.Form.RecordsetClone
r.MoveFirst
Do
If...
|
by: jack2019x |
last post by:
hello, Is there code or static lib for hook swapchain present?
I wanna hook dxgi swapchain present for dx11 and dx9.
| |