Forms and hidden fields

R

Roshawn Dawson

Hi,

Are hidden fields passed in the querystring when a form is posted back?
If they are, must the hidden fields be server controls in order to
access them from .net code?

Thanks,
Roshawn
 
A

Andy Fish

No, they are passed in a form post which is different from a query string
(but has a similar effect)

AFAIK you can access them directly as Request["myHiddenField"] or
Request.Form["myHiddenField"]

but if you want to access them as server controls you can do that as well,
just declare them in the usual way:

<input type="hidden" runat="server" id="myHiddenField" name="myHiddenField"
value="xyz">

I always make the ID and Name the same in this case - it's not strictly
necessary but a lot less confusing.
 
C

Curt_C [MVP]

Roshawn said:
Hi,

Are hidden fields passed in the querystring when a form is posted back?
If they are, must the hidden fields be server controls in order to
access them from .net code?

Thanks,
Roshawn

no..not in the QueryString but if the input is of type=hidden then yes
they are passed.
 
R

Roshawn Dawson

Thanks guys for your prompt responses.

It seems that one of you says that hidden fields are not passed in the
querystring while the other says the opposite. Perhaps I wasn't clear
enough.

What I mean by hidden fields is hidden form fields. You know, the input
fields whose type is specified as hidden, like this:

<input type="hidden" name="227" id="227" value="stuff that is hidden" />

Are such fields included in the querystring or not?

Thanks,
Roshawn
 
G

Guest

Hi,

If you are using method="post" in your form element, the hidden fields will
be sent in the Request Collection when you submit the form.

If you are using the method="get", it will be sent in the query string
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top