Add attribute to checkbox so it can fire button click event

24 Views Asked by At

I have a button on my page which is a trigger for an update panel. The page does not refresh and all the variables on the page (sender) go into the btncalcsave_click event just fine when I click the button. Instead of having to check a checkbox and click the button that is wired to the click event, I want to be able to just click the checkbox and btncalcsave_click will fire just as when I click the button. How is this achieved?

I tried to add a trigger to the update template (cbbiweekly) which is the id of the checkbox but this doesn't work. Does the checkbox need to have an Onclick attribute added to it in order for this to work? I am unclear how to get this working.

<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">
1

There are 1 best solutions below

0
Scot On

I have both my 2 checkboxes and even the dropdown working as a trigger.

<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" />