mercredi 1 février 2023

Checkbox doesn't work on first click when checked by default

I have some checkboxes that doesn't work in first click when they are already checked by default.

What's happen is: When I click in te checked checkbox he fire Page_Load but doesn't fire OnCheckedChanged event and keep checked until I click again(after this all checkboxes start to work normally).

In the tests I made, I notice that if I keep the Panel witch include the checkboxes always visible this problem does not occur and if I remove the OnCheckedChanged event too

 <asp:UpdatePanel runat="server" ID="updApply">
    <ContentTemplate>
        <div class="row">
            <div class="col-md-12">
                <asp:Panel runat="server" ID="pnlApply">
                    <div class="row">
                        <div class="col-md-12">
                            <asp:Panel runat="server" ID="pnlAplicaDescontoEstabelecimento">
                                <div class="form-group">
                                    <div class="input-group">
                                        <div class="input-group-addon">
                                            <asp:CheckBox ID="cbxApply" runat="server" 
                                                onchange="loadUI();" 
                                                OnCheckedChanged="apply_CheckedChanged" 
                                                AutoPostBack="True" />
                                        </div>
                                    </div>
                                </div>                                                    
                            </asp:Panel>
                        </div>
                    </div>
                </asp:Panel>
            </div>
        </div>
    </ContentTemplate>
</asp:UpdatePanel>

I think it's important to say that in the code behind there are some functions that control whether the Panel is visible

Thanks!




Aucun commentaire:

Enregistrer un commentaire