我正在开发一个使用asp.net和C#的网站。使用JavaScript评估RadioButtonList控件 - ASP.Net
我正在使用RadioButtonList控件。下面显示了RadioButtonList的代码片段:
<asp:RadioButtonList ID="RLCompareParameter" runat="server"
RepeatDirection="Horizontal" meta:resourcekey="rsKey_RLCompareParameter"
AutoPostBack="True"
onselectedindexchanged="RLCompareParameter_SelectedIndexChanged">
<asp:ListItem Selected="True" Value="Forms" meta:resourcekey="rsKey_RLCompareParameterListItemForms" Text="Forms"></asp:ListItem>
<asp:ListItem Value="Segments" meta:resourcekey="rsKey_RLCompareParameterListItemSegments" Text="Segments"></asp:ListItem>
<asp:ListItem Value="Questions" meta:resourcekey="rsKey_RLCompareParameterListItemQuestions" Text="Questions"></asp:ListItem>
</asp:RadioButtonList>
在同一页面有一个按钮。点击那个按钮时,我想使用javascript显示基于选定电台列表项的提醒信息。我的javascript函数的某些部分如下所示
var RLCompareParameter = this.document.getElementById("<%= RLCompareParameter.ClientID %>");
if (RLCompareParameter.SelectedValue == "Forms") {
if (document.getElementById("<%= lbAvailableForms.ClientID %>").value == "") {
alert("Please select a form from Available Evaluation Forms ");
return false;
}
} else if (RLCompareParameter.SelectedValue == "Segments") {
if (document.getElementById("<%= lbAvailableSegments.ClientID %>").value == "") {
alert("Please select a segment from the available segments ");
return false;
}
} else if (RLCompareParameter.SelectedValue == "Questions") {
if (document.getElementById("<%= lbAvailableQuestions.ClientID %>").value == "") {
alert("Please select a Question from the available questions");
return false;
}
}
但如果(RLCompareParameter.SelectedValue ==“一些价值”)始终为false。我认为没有任何属性像RadioButtonList控件的选定值。我希望有人能帮我
什么是错误信息? – 2010-11-08 10:19:31
哦对不起。我打错了。没有错误。看到编辑的问题,只是绕过if语句。我不知道如何评估使用JavaScript的RadioButtonList。是abpve java代码片断是正确的?谢谢 – 2010-11-08 11:04:23