Confirm client side RadioButtonGroup
<asp:RadioButton GroupName="EndorsementType" runat="server" ID="rdoAddProperty" Text="Add Property to TIV" />
<asp:RadioButton GroupName="EndorsementType" runat="server" ID="rdoRemoveProperty" Text="Remove Property from TIV" />
<asp:RadioButton GroupName="EndorsementType" runat="server" ID="rdoChangeProperty" Text="Change Property Values" />
I was thinking about implementing a custom validator
and using a client function JavaScript
to reference the RadioButton ID (I am using web forms, not mvc),
something like..
if(document.getElementById(<%= rdoAddProperty.ClientId %>).checked == true) && ...
Does anyone know a way to do this without knowing the clientId?
+1
Nathan prather
source
to share
2 answers
If your radios are contained in something like a DIV, and because your asp: RadioButtons will appear as HTML inputs, you can do something like:
<script type="text/javascript" language="javascript">
function Validate()
{
var l_elemsRadios = document.getElementById("MyRadios").getElementsByTagName("input");
if (l_elemsRadios == null)
return;
for (var i = 0; i < l_elemsRadios; i++)
{
// validate l_elemsRadios[i] through l_elemsRadios[n]
}
}
</script>
<div id="MyRadios">
<input type="radio" name="EndorsementType" value="Remove Property from TIV" >Remove Property from TIV
.
.
.
</div>
+3
Bullines
source
to share
You will need to put your client ID in the form, as with INamingContainer your ID can change in relation to other information stored on the server.
0
Mitchel Sellers
source
to share