我遇到了一个问题,第一个单选按钮的checked changed事件没有触发。我启用了
ViewState
,但问题仍然存在。请看下面的代码:<span class="pull-right text-right">
<label class="inline radio">
<asp:RadioButton runat="server" ID="rdoViewAll" CausesValidation="false" GroupName="Filter" Text="View All" AutoPostBack="true" EnableViewState="true" Checked="true" />
</label>
<label class="inline radio">
<asp:RadioButton runat="server" ID="rdoViewCurrent" CausesValidation="false" GroupName="Filter" Text="View Current" AutoPostBack="true" />
</label>
<label class="inline radio">
<asp:RadioButton runat="server" ID="rdoViewFuture" CausesValidation="false" GroupName="Filter" Text="View Future" AutoPostBack="true" />
</label>
</span>
我在 Page_Init
中设置了以下的选中改变事件:
public void Page_Init(object sender, EventArgs e)
{
this.rdoViewAll.CheckedChanged += (s, a) =>
{
RebindTerms();
};
this.rdoViewFuture.CheckedChanged += (s, a) =>
{
RebindTerms();
};
this.rdoViewCurrent.CheckedChanged += (s, a) =>
{
RebindTerms();
};
}
我注意到的一件事是,当我在第一个单选按钮上删除Checked="true"
属性时,CheckedChanged
事件会成功触发。然而,我需要在页面加载时默认选中第一个单选按钮。