向复选框添加属性,以便它可以触发按钮单击事件

问题描述 投票:0回答:1

我的页面上有一个按钮,可以触发更新面板。当我单击按钮时,页面不会刷新,页面(发送者)上的所有变量都会进入 btncalcsave_click 事件。我希望能够只单击复选框,然后 btncalcsave_click 就会像单击按钮时一样触发,而不必选中复选框并单击连接到单击事件的按钮。这是如何实现的?

我尝试向更新模板(cbbiweekly)添加一个触发器,它是复选框的 id,但这不起作用。复选框是否需要添加 Onclick 属性才能正常工作?我不清楚如何让它发挥作用。

<asp:CheckBox ID="cbbiweekly" runat="server" Text="Bi-Weekly Pmt Schedule" Font-Size="x-Small"  OnClientClick="btncalcsave_Click" />

<asp:UpdatePanel ID="udppmtschedule" runat="server" UpdateMode="Conditional">
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btncalcsave" />
            <asp:AsyncPostBackTrigger ControlID="cbbiweekly" />
        </Triggers>
        <ContentTemplate>
            <table width="450px">
checkbox updatepanel
1个回答
0
投票

我有两个复选框,甚至下拉菜单都可以作为触发器。

<asp:UpdatePanel ID="udppmtschedule" runat="server" UpdateMode="Conditional">
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btncalcsave" />
            <asp:AsyncPostBackTrigger ControlID="cbbiweekly" />
            <asp:AsyncPostBackTrigger ControlID="cbioinitialperiod" />
            <asp:AsyncPostBackTrigger ControlID="ddlpmtratetype" />
        </Triggers>

 <asp:DropDownList ID="ddlpmtratetype" runat="server" Width="130" AutoPostBack="True" OnSelectedIndexChanged="btncalcsave_Click">
                                <asp:ListItem Value="">-Select-</asp:ListItem>
                                <asp:ListItem Value="Start Rate">Start Rate</asp:ListItem>
                                <asp:ListItem Value="% Below Note Rate">% Below Note Rate</asp:ListItem>
                                <asp:ListItem Value="% of Fully Amortized Pmt">% of FullAm or IO Pmt</asp:ListItem>
                            </asp:DropDownList>

 <asp:CheckBox ID="cbbiweekly" runat="server" Text="Bi-Weekly Pmt Schedule" Font-Size="x-Small" oncheckedchanged="btncalcsave_Click" AutoPostBack="True" />
© www.soinside.com 2019 - 2024. All rights reserved.