RadioButtonList如下所示,没有自动回发 . 我的问题是当我选择选项1(值1)并单击任一链接按钮时,后面的代码中的变量NotifyMe始终为true,因为所选项始终是默认值 . 我试图为此RadioButtonList设置EnableViewState,并保留没有ViewState的表单重置 . 它也没用 . 谢谢您的帮助 .
<div id="preferencePopup" style="display: none" title="Set Preference">
Select an option than click either of the button below.
<div>
<ul id="preferenceOptions">
<li>
<asp:RadioButtonList ID="PreferenceNotification" runat="server" CssClass="radioButtonNoBorder">
<asp:ListItem Text="No notification" Value="1" />
<asp:ListItem Text="Notification" Value="2" selected="true" />
</asp:RadioButtonList>
</li>
</ul>
</div>
<div class="col-md-offset-1 col-md-11 col-sm-12 text-center">
<asp:LinkButton ID="btnSavePreference" runat="server" OnClick="btnSavePreference_Click" CssClass="btn btn-default">Clear & Save</asp:LinkButton>
<asp:LinkButton ID="btnAddAndSave" runat="server" OnClick="btnSavePreference_Click" CssClass="btn btn-default">Add & Save</asp:LinkButton>
</div>
</div>
protected void btnSavePreference_Click(object sender, EventArgs e) {
bool NotifyMe = PreferenceNotification.SelectedItem.Value == "2" ? true : false;
}