Click here to Skip to main content
15,892,480 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

1 solution

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:
JavaScript
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.
 
Share this answer
 
Comments
Shruthi.BT 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. 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900