Request.Form.GetValues();

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am dynamically creating htmlinputcheckbox controls. Each of these will have
a name,id and value.

The user make a selection by checking the checkboxes. I then want to
retrieve the the checkboxes selected.

Where i am having difficulties is that these htmlinputcheckboxes are not
part of a control collection, so i am baffled as to how i can retrieve them
using
Request.Form.GetValues();

How can I get retrieve which checkboxes have been checked by the user?

thank you.
 
Hi,

Doesn't ASP .NET allow creating server-side checkbox controls? If you create
those dynamically, they must become a part of the control collection, given
you re-create them in the same quantity and order on postback.

P.S. I haven't had experience with ASP .NET for more than a year for now, so
I apologize beforehand if I am giving some incorrect information. I remember
it worked for me in a similar to the described way, but I can be obviously
missing certain details.
 
thank you.
Can you tell me when you would explicitly require using htmlcontrols rather
than a web server control and maybe describe an example.

thx

Dmytro Lapshyn said:
Hi,

Doesn't ASP .NET allow creating server-side checkbox controls? If you create
those dynamically, they must become a part of the control collection, given
you re-create them in the same quantity and order on postback.

P.S. I haven't had experience with ASP .NET for more than a year for now, so
I apologize beforehand if I am giving some incorrect information. I remember
it worked for me in a similar to the described way, but I can be obviously
missing certain details.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]


CodeRazor said:
I am dynamically creating htmlinputcheckbox controls. Each of these will
have
a name,id and value.

The user make a selection by checking the checkboxes. I then want to
retrieve the the checkboxes selected.

Where i am having difficulties is that these htmlinputcheckboxes are not
part of a control collection, so i am baffled as to how i can retrieve
them
using
Request.Form.GetValues();

How can I get retrieve which checkboxes have been checked by the user?

thank you.
 
CodeRazor,

When you are creating your controls dynamically, you are using some
prefix and an identifier, like "checkbox1", "checkbox2", "checkboxN".

All you have to do is check for the existence for the value upon return,
incrementing the index (1, 2, N) until the values returned from the form
indicate that there are no more checkboxes to check.

Hope this helps.
 
Hi,
Can you tell me when you would explicitly require using htmlcontrols
rather
than a web server control and maybe describe an example.

I think you can use HTML controls whenever you do not have to handle them on
server in any way (say, it's a JavaScript-based survey which collects and
pre-processes the user input on the client and then submits a form with a
hidden field to the server).

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]


CodeRazor said:
thank you.
Can you tell me when you would explicitly require using htmlcontrols
rather
than a web server control and maybe describe an example.

thx

Dmytro Lapshyn said:
Hi,

Doesn't ASP .NET allow creating server-side checkbox controls? If you
create
those dynamically, they must become a part of the control collection,
given
you re-create them in the same quantity and order on postback.

P.S. I haven't had experience with ASP .NET for more than a year for now,
so
I apologize beforehand if I am giving some incorrect information. I
remember
it worked for me in a similar to the described way, but I can be
obviously
missing certain details.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]


CodeRazor said:
I am dynamically creating htmlinputcheckbox controls. Each of these will
have
a name,id and value.

The user make a selection by checking the checkboxes. I then want to
retrieve the the checkboxes selected.

Where i am having difficulties is that these htmlinputcheckboxes are
not
part of a control collection, so i am baffled as to how i can retrieve
them
using
Request.Form.GetValues();

How can I get retrieve which checkboxes have been checked by the user?

thank you.
 
Back
Top