单选按钮检查更改甚至不触发

Kno*_*are 4 vb.net asp.net checkbox radio-button

我在用户控件中有 2 个单选按钮,并且控件已注册到页面。当我点击单选按钮时,事件(CheckChanged)没有触发。

<asp:View ID="viewfirst" runat="server">
                    <asp:UpdatePanel ID="updatepanel1" runat="server" UpdateMode="Always">
                        <ContentTemplate>

                            <asp:RadioButton ID="radio1" Text="Yes" Enabled="true" runat="server" />
                            <asp:RadioButton ID="radio2" Text="No" Enabled="true" runat="server" />
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </asp:View>

Below is code in behind file of the control. 


 Protected Sub radio1_CheckedChanged(sender As Object, e As EventArgs) Handles radio1.CheckedChanged
    //
    //
End Sub
Run Code Online (Sandbox Code Playgroud)

看起来一切都很好,但有些地方不对劲。你能告诉我吗。

小智 5

为复选框设置autopostback=true - 这将触发事件

UpdateMode=conditionalChildrenAsTriggers=false对于 UpdatePanel - 所以当你触发复选框时,它不会触发完整的回发