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. General Programming
  3. C#
  4. findControl & checkbox state

findControl & checkbox state

Scheduled Pinned Locked Moved C#
questioncsharpasp-netdockerhelp
3 Posts 3 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.
  • E Offline
    E Offline
    esakal
    wrote on last edited by
    #1

    Hello, I'm programming in .net enviroment (asp.net in c#). i would like to ask two seperate questions: question 1 I would like to find control in a form during run-time using "this.Page.FindControl("ctl")" the problem is that the control is nested somewhere inside (i.e inside panels or place holders) thus when running the above command i recieve nothing. how can i find the control? must i create a function that loop on the controls of the page and when it reachs a control that has container, it searches inside (recursive)? is it not bad for performances? question 2 I have a photo gallery divided into pages. the pictures are shown in DataList. Above each photo i have a checkbox which alow the user to select it. When moving between pages I would like the application to "remember" the checkbox that were chosen for two reasons: 1. when the user return to a page were several photos were selected, their checkbox will be checked. 2. when the user press a "send" button, a list of all the photos will be send (not only those that are shown on the current page). Please advice how to do so. Eran Sakal.

    L S 2 Replies Last reply
    0
    • E esakal

      Hello, I'm programming in .net enviroment (asp.net in c#). i would like to ask two seperate questions: question 1 I would like to find control in a form during run-time using "this.Page.FindControl("ctl")" the problem is that the control is nested somewhere inside (i.e inside panels or place holders) thus when running the above command i recieve nothing. how can i find the control? must i create a function that loop on the controls of the page and when it reachs a control that has container, it searches inside (recursive)? is it not bad for performances? question 2 I have a photo gallery divided into pages. the pictures are shown in DataList. Above each photo i have a checkbox which alow the user to select it. When moving between pages I would like the application to "remember" the checkbox that were chosen for two reasons: 1. when the user return to a page were several photos were selected, their checkbox will be checked. 2. when the user press a "send" button, a list of all the photos will be send (not only those that are shown on the current page). Please advice how to do so. Eran Sakal.

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      esakal wrote: I'm programming in .net enviroment (asp.net in c#). Then use the ASP.NET forum for that :) xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots

      1 Reply Last reply
      0
      • E esakal

        Hello, I'm programming in .net enviroment (asp.net in c#). i would like to ask two seperate questions: question 1 I would like to find control in a form during run-time using "this.Page.FindControl("ctl")" the problem is that the control is nested somewhere inside (i.e inside panels or place holders) thus when running the above command i recieve nothing. how can i find the control? must i create a function that loop on the controls of the page and when it reachs a control that has container, it searches inside (recursive)? is it not bad for performances? question 2 I have a photo gallery divided into pages. the pictures are shown in DataList. Above each photo i have a checkbox which alow the user to select it. When moving between pages I would like the application to "remember" the checkbox that were chosen for two reasons: 1. when the user return to a page were several photos were selected, their checkbox will be checked. 2. when the user press a "send" button, a list of all the photos will be send (not only those that are shown on the current page). Please advice how to do so. Eran Sakal.

        S Offline
        S Offline
        Sebrell
        wrote on last edited by
        #3

        for question 1, are you searching for a Control whose Id value you set at design-time? that is, can you use document.getElementById(knownControlId) in client-side javascript? for question2, I'd try using <input type="hidden" id="ipt_[associated Image Id]" value="false" /> then use script (I'm big on client-side script) to handle the checkbox onclick event.

        function checkboxClicked(checkBox){

        var sId = checkBox.id;

        if (sId){

        // use a naming convention to convert to the id of the input

        var inputElem = document.getElementById(sId);

        if (inputElem && inputElem.value) {

        inputElem.value = "true";

        }

        }

        }

        Then add onclick="checkBoxClicked(this);" for each checkbox. This approach, although it relies on a naming convention, allows you to have access to the information on both server and client side. HTH

        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