Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. How can I access child controls of a web form?

How can I access child controls of a web form?

Scheduled Pinned Locked Moved Web Development
questionsysadminhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rudy net
    wrote on last edited by
    #1

    I have a web page with a asp:checklistbox object. I have buttons to "check all" checkboxes; however, to avoid the roundtrip back to the server, I was wondering if I could use jscript to set the checkboxes in the client. The problem I have is how do I access all of the checkboxes that get automatically generated by the checklistbox? If I can access all the checklistboxes of the form then I could set their value to checked.

    C 1 Reply Last reply
    0
    • R rudy net

      I have a web page with a asp:checklistbox object. I have buttons to "check all" checkboxes; however, to avoid the roundtrip back to the server, I was wondering if I could use jscript to set the checkboxes in the client. The problem I have is how do I access all of the checkboxes that get automatically generated by the checklistbox? If I can access all the checklistboxes of the form then I could set their value to checked.

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      I can't remember exactly how I did this, but I can tell you the steps to discover it. * Look at the output of the webpage - That is, look at source that you get in the browser. * Examine the IDs of the checkboxes in the list and see how they compare to the name you gave the asp:checklistbox (IIRC they will have something appended to the name, and perhaps something prefixed if it is contained in another control) * Write some javascript to use the pattern you have discovered.


      My: Blog | Photos "Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious

      R 1 Reply Last reply
      0
      • C Colin Angus Mackay

        I can't remember exactly how I did this, but I can tell you the steps to discover it. * Look at the output of the webpage - That is, look at source that you get in the browser. * Examine the IDs of the checkboxes in the list and see how they compare to the name you gave the asp:checklistbox (IIRC they will have something appended to the name, and perhaps something prefixed if it is contained in another control) * Write some javascript to use the pattern you have discovered.


        My: Blog | Photos "Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious

        R Offline
        R Offline
        rudy net
        wrote on last edited by
        #3

        Colin, Thanks for your input. You guided me into the right direction. Following is the solution in case anyone needs it as well: <script language=vbscript> option explicit <!---------------- check/clear text boxes -------------> dim currChkboxName dim currCheckValue sub UpdateCheckboxes(chkboxName, checkValue) currChkboxName = chkboxName currCheckValue = checkValue dim i for i = 0 to Form1.children.length-1 UpdateChildCheckboxes Form1.children(i) next end sub sub UpdateChildCheckboxes(obj) dim i if not obj is nothing then if obj.id <> "" then if InStr(1, obj.id, currChkboxName) > 0 then obj.checked = currCheckValue end if end if for i = 0 to obj.children.length UpdateChildCheckboxes obj.children(i) next end if end sub </script> Then declare the buttons as follows: <input id="btnClearTestConditions" type=button value="Clear All" onClick="UpdateCheckboxes 'cklTestConditions_', false" /> <input id="btnCheckAllTestConditions" type=button value="Check All" onClick="UpdateCheckboxes 'cklTestConditions_', true" >

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups