I have two checkboxes in Detailview templatefield in Sharepoint inside a Usercontrol. I just want only one checkbox to be selected at a time
this is what I am doing so far
in my Default.ascx page I have the following Javascript code
<script type='text/javascript'>
var checkedObject = null;
function isChecked(what) {
if (checkedObject == null) {
checkedObject = what;
return true;
}
else {
if (what == checkedObject) {
if (!what.checked) {
checkedObject = null;
return true;
}
}
else {
//alert('You can only choose one option');
return false;
}
}
}
</script>
and in my Default.ascx.cs I have following lines in my Page_Load event
CheckBox chkV = (CheckBox)dvNotes.FindControl("chkV");
CheckBox chkS = (CheckBox)dvNotes.FindControl("chkS");
chkV.Attributes.Add("onclick", "javascript:isChecked(this);");
chkS.Attributes.Add("onclick", "javascript:isChecked(this);");
Its not working, is there any other way to accomplish this
Thanks,
Moe
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.