我有两个 RadioButtonList,一个是 ASP.NET RadioButtonList,另一个是一系列 HTML 输入单选项,具有共同的组名。
单选按钮单击的 javascript 调用了服务器端WebMethod
以设置一个值,然后当它返回时,我想设置 asp 单选按钮中的一个单选按钮以触发 ASP 事件。这样服务器将发送回一个包含更新对象的新页面。
<asp:RadioButtonList Visible="true"
Height="1" Width="1"
ID="MyArticleHistory"
runat="server"
AutoPostBack="true"
OnSelectedIndexChanged="MyArticleHistory_SelectedIndexChanged"
RepeatDirection="Horizontal">
<asp:ListItem id="OneDayRadioBtn" runat="server" Value="1-Day" />
<asp:ListItem id="ThreeDayRadioBtn" runat="server" Value="3-Days" />
</asp:RadioButtonList>
<input type="radio"
name="MyHTMLArticleHistory"
id="HtmlOneDay"
value="htmlOneDayRadioBtn"
checked
onchange="OneDayChecked()"> 1-Day
<input type="radio"
name="MyHTMLArticleHistory"
id="HtmlThreeDay"
value="htmlThreeDayRadioBtn"
onchange="ThreeDayChecked()"> 3-Days
... Java 脚本是
function OneDayChecked()
{
alert("We're inside 1 day");
PageMethods.setTimeFilter(0);//0 is the index for the 1-day
document.getElementById('<%=OneDayRadioBtn.Selected%>').value = true;
//Q: This should cause the asp radio button to change selected index
// resulting in a call to the server, correct?
}
如何从 javascript 中触发 asp 单选按钮 onSelectedIndexChange?