Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.0 ASP.NET
hi,
 
i am working on a page which binds all the checkbox and its values dynamically... if any checkbox is clicked i need to open the div next to the checkbox that is clicked.... the div that needs to open next to any checkbox that is clicked is a single div so any check box is clicked that same div should open.. but it should open next to the checkbox that is clicked... for example :
 

checkbox1 --- india
checkbox2 --- US
 
if any of the checkbox is clicked i need to open a div which is common having colors like
 
red
blue
green
black
 
within a vertical div... this div opens but not next to the checkbox which is clicked but somewhere else.. means for ex: if india is checked i need the common color div to open next to india and when US is clicked i need colors div to open next to US.
 

How can this be done using C#.net or ASP.Net please help!!
 
Thanking you in advance!!
Posted 11-Mar-13 3:38am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You should show/hide the div using client-side scripting, else you need to perform a postback to the server and reload (at least part of) the page.
 
option 1:
You can add an onclick (I believe) handler that calls a client-side function.
 
I ussually do something like this:
function on_checkbox_clicked(checkboxid, divid){
  if(document.getElementById(divid).style.visibility == "hidden"){
    document.getElementById(divid).style.visibility = "visible";
  }
  else{
     document.getElementById(divid).style.visibility = "hidden";
  }
}
 
it will be a little more complex than that, but you get the idea. positioning the div tags is done through html and css.
 
option 2:
Have a look here: JQuery UI[^] which gives very nice results fast, but is a bit more complex.
 
hope this gets you along the way.
  Permalink  
Comments
Shruthi.BT at 13-Mar-13 2:05am
   
hi... i cannot use the concept of hide show as i am not going to get the checkbox id... as it is dynamically generated so for a list of checkboxes id will be say rad0 then the next set of checkbox will have id rad1.... so since the id and no. of checkbox i will not know i cannot use the visible hide concept....
 
so i have another div which needs to open next to the checkbox which is checked assuming [] as checkbox.. what i need is as follows...
 
i need like this...
 
[]1
[checked]2 []red
[]3 []blue
[]4 []green
[]5 []yellow
[]6
[]7
[]8
 
the colors div should open next to [](checkbox that is checked) so if i check the checkbox 3 for example then that div should open as:
 
[]1
[]2
[checked]3 []red
[]4 []blue
[]5 []green
[]6 []yellow
[]7
[]8
 
how can i make the div to display next to the checkbox that is checked .. and that colors is a single div...
 
Please help!!
V. at 13-Mar-13 2:53am
   
There is a property ClientId I believe that allows you to control the clientid for your control.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 406
1 /\jmot 180
2 Suraj Sahoo | Coding Passion 170
3 BillWoodruff 159
4 Afzaal Ahmad Zeeshan 154
0 OriginalGriff 8,344
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,634
3 Maciej Los 5,024
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 11 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100