ClientID and Request.form()

C

cannontrodder

I am writing a composite control that allows two-way binding between a
collection of boolean values and a set of checkboxes.

In the CreateChildControls, I add each checkbox control that I need and
give it a numbered id/name while setting it's checked property as per
the values in my boolean collection.

When I create the control on postback, I pull the datasource out of
viewstate and re-create the checkboxes again with the data source but
at this point I also need to see if any of the checkboxes were changed
on the client and update the datasource as appropriate. I know this
seems odd but it lets me use formview/detailsview to update boolean
data by two-way databinding using the objectdatasource.

Anyway, my question!

The ClientID property of the parent control happens to be
"FormView1_Checklist1_whateverid" so I iterate through the request.form
collection looking for checkboxes that were actually checked. They are
called "FormView1$Checklist1$whateverid".

Am I going to be ok to just replace _ with $ when looking for this
POSTed data or is there another more appropriate way for me to access
posted data?
 
T

Teemu Keiski

You don't need to replace. UniqueID property returns the ID which is used as
key in POST collection (in Request.Form)

Another thing. If you add them as controls (and recreating on postback
doesn't happen with databinding) they should fire CheckedChanged event in
which you should get which ones were changed.

-
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top