Click to See Complete Forum and Search --> : How to get values from dynamically generated checkboxes


Farhad
October 10th, 2003, 02:56 AM
I have an ASP.NET on which i dynamically generate HTML checkboxes; with dynamic names like

ckbUser2
ckbUser3
ckbUser4
.
.
.
ckbUser9
ckbUser10

(the numbering sequence may vary; not necessarily in sequence)

On a button click i want to get values from all these checkboxes in C# code.

Please tell me how can i read values from checkboxes.


Thanks in advance

vdpramesh
October 10th, 2003, 05:27 AM
Hope thsi fn will get the values of dynamically created chk boxes.

function fnCaptureValues()
{
var valEvents = "";
var TotChkBox
TotChkBox=window.document.frmpagename.hidNoChkval.value;
for ( i=0 ; i < TotChkBox ; i++ )
{
if (TotChkBox==1)
{
if (document.forms[0].chkboxarray.checked==true)
{
valEvents = valEvents + document.forms[0].chkboxarray.id + "$"
}
}
else
{
if (document.forms[0].chkboxarray[i].checked==true)
{
valEvents = valEvents + document.forms[0].chkboxarray[i].id + "$"
}
}
}
document.frmpagename.lblValues.value = valEvents;
if (document.frmpagename.lblValues.value == "")
{
alert("Please select at least one .");
return false;
}
else
{
var agree = confirm("Are you sure you want to remove ?");
if (agree)
return true ;
else
return false ;
}
}
</script>

Farhad
October 10th, 2003, 08:29 PM
I want to get these values on server side in my C# code file.

How will i get them there.