The problem is the HTML code generated for ASP.NET code
<table id="RadioBtn" border="0">
<tr>
<td>
<input id="RadioBtn_0" type="radio" name="RadioBtn" value="Male" /><label for="RadioBtn_0">Male</label>
</td>
<td>
<input id="RadioBtn_1" type="radio" name="RadioBtn" value="Female" /><label for="RadioBtn_1">Female</label>
</td>
</tr>
</table>
<input type="submit" name="Button1" value="" onclick="as();" id="Submit1" />
you see everything in ASP.NET will be rendered to HTML for client and you will get above. if the above RadioButtonList control is inside some other control or you have master page the ID of the table will be different and when you are trying to document.getElementById(...) it results in undefined.
Always make sure your javascript is aligned with the client code generated for ASP.net code. you can do right click > view source in web browser.
To solve it replace your javascript code with below code
<script type="text/javascript">
function as()
{
var tableID = '<%= RadioBtn.ClientID %>';
var radioButtons = document.getElementsByName(tableID)
var totalRows = radioButtons.length;
var radioButton;
var flagRadioButtonChecked = false;
for(var rowIndex=0; rowIndex< totalRows; rowIndex++)
{
radioButton = radioButtons[rowIndex]
if(radioButton.type == 'radio')
{
if(radioButton.checked)
{
flagRadioButtonChecked=true;
break;
}
}
}
if(flagRadioButtonChecked)
{
alert(radioButton.value + ' is checked...');
}
}
</script>
Hope this will help.
Thanks,
Hemant