Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 24th, 2009, 07:43 PM
Authorized User
 
Join Date: May 2007
Posts: 73
Thanks: 4
Thanked 0 Times in 0 Posts
Default Get dynamic text box values

Hi,
I got some check boxes appears on a form. The number of check boxes vary from user to user.
Now i want to get the values of all the check boxes that appear on the page once user click the submit button, but the problem is How to get the values of those dynamic check box on the landing page as their name generates dynamically (ck_01, ck_02...)

I tried to use Request.form.count but it returns all the elements... so is there any way to filter it?


Cheers
S
__________________
Cheers
Sheraz
 
Old August 25th, 2009, 05:02 AM
Authorized User
 
Join Date: May 2007
Posts: 73
Thanks: 4
Thanked 0 Times in 0 Posts
Default

Any one on above?
__________________
Cheers
Sheraz
 
Old August 25th, 2009, 07:52 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi..

Did you try with find control?? even not knowing the exact control name, since they are dynamic you create them so you know how to look for them.
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old August 25th, 2009, 08:47 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 207
Thanks: 2
Thanked 15 Times in 15 Posts
Default More info please...

First are you posting to another page? or are you posting to the same page?
Also you probably want to set the viewstate to true if on the same page.

How are you creating the names? are they like you said ck_01, ck_02, etc...

Instead of just creating to checkboxes on the page I would use a container for them that only houses the dynamic checkboxes, that way you don't need to filter if they are the ones you dymanically created...


Either way you can do it with a loop.


With out using a container:
Code:
For Each con As Control In Page.Controls
  If TypeOf con Is CheckBox Then
     If CType(con, CheckBox).ID.StartsWith("ck_") Then
        If CType(con, CheckBox).Checked = True Then
            'Do what you need to do with the value - CType(con, CheckBox).Value
        End If
     End If
  End If
Next
The above code could be simplified but I did that so you could easily follow what was being done.


Now if you add a panel or something to your page and just create your checkboxes there then you don't need to loop all the controls of the page or validate that they are the dynamic ones because you already know they are...

With Container:
Code:
For Each con As Control In CheckBoxPanel.Controls
   If TypeOf con Is CheckBox Then
     If CType(con, CheckBox).Checked = True Then
         'Do what you need to do with the value - CType(con, CheckBox).Value
     End If
   End If
Next
Hopefully I understand you correctly and this at least points you in the correct direction....
__________________
Jason Hall

Follow me on Twitter @jhall2013





Similar Threads
Thread Thread Starter Forum Replies Last Post
Grab Values From List Box into Text Box phungleon VB How-To 2 June 19th, 2008 10:33 PM
Can't set text property of dynamic text box sreerajrs ASP.NET 1.0 and 1.1 Professional 1 May 31st, 2006 09:39 PM
Dynamic select box from database values pk_jsp Javascript 1 May 4th, 2005 01:45 AM
loop values and text box values move mateenmohd Classic ASP Basics 2 April 5th, 2005 11:33 PM
dynamic text box harpua Flash (all versions) 2 November 24th, 2004 09:16 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.