R
RodBillett
I have a situation where I have 3 checkboxes - and at least 1 needs to be
selected at all times...
I have implemented the code that allows this behavior to happen, BUT
Viewstate gets all messed up. As long as none of the checkboxes are
disabled, viewstate works fine - and client actions are 'remembered' after a
postback. but when I have one checkbox and it is disabled, then when I
postback, ALL checkboxes get the unchecked value.
Thanks
Rod
on the server, when I create the checkboxes, i add the following attribute
to all. and they are defaulted to all 'Checked=true"
SearchWhat_Annotations.Attributes.Add( "onclick", "AlwaysOneChecked(
this.form )" );
<Client Script>
function AlwaysOneChecked( thisForm )
{
var CheckedCount = CheckedCount = (thisForm.SearchContents.checked?1:0) +
(thisForm.SearchProfiles.checked?1:0) +
(thisForm.SearchAnnotations.checked?1:0);
if ( CheckedCount == 1 )
{
thisForm.SearchContents.readonly =
(thisForm.SearchContents.checked?true:false)
thisForm.SearchProfiles.disabled =
(thisForm.SearchProfiles.checked?true:false)
thisForm.SearchAnnotations.disabled =
(thisForm.SearchAnnotations.checked?true:false)
}
else
{
thisForm.SearchContents.disabled = false;
thisForm.SearchProfiles.disabled = false;
thisForm.SearchAnnotations.disabled = false;
}
}
selected at all times...
I have implemented the code that allows this behavior to happen, BUT
Viewstate gets all messed up. As long as none of the checkboxes are
disabled, viewstate works fine - and client actions are 'remembered' after a
postback. but when I have one checkbox and it is disabled, then when I
postback, ALL checkboxes get the unchecked value.
Thanks
Rod
on the server, when I create the checkboxes, i add the following attribute
to all. and they are defaulted to all 'Checked=true"
SearchWhat_Annotations.Attributes.Add( "onclick", "AlwaysOneChecked(
this.form )" );
<Client Script>
function AlwaysOneChecked( thisForm )
{
var CheckedCount = CheckedCount = (thisForm.SearchContents.checked?1:0) +
(thisForm.SearchProfiles.checked?1:0) +
(thisForm.SearchAnnotations.checked?1:0);
if ( CheckedCount == 1 )
{
thisForm.SearchContents.readonly =
(thisForm.SearchContents.checked?true:false)
thisForm.SearchProfiles.disabled =
(thisForm.SearchProfiles.checked?true:false)
thisForm.SearchAnnotations.disabled =
(thisForm.SearchAnnotations.checked?true:false)
}
else
{
thisForm.SearchContents.disabled = false;
thisForm.SearchProfiles.disabled = false;
thisForm.SearchAnnotations.disabled = false;
}
}