1

I have a form inside a Bootstrap 3 collapsible panel.

The form is an asp.net DetailsView control with EDIT and DELETE buttons.

When I click on EDIT the panel collapses and I need to click on it again to reopen it and finish editing.

The EDIT button click event causes the panel to close.

Why? How do I prevent that?

Here's the markup (note: the accordion is inside an UpdatePanel):

<div class="panel panel-default">
    <div class="panel-heading" role="tab" id="headingTwo">
         <h4 class="panel-title">
            <a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">Associated Person Details
            </a>
              </h4>

    </div>
    <div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
        <div class="panel-body">
            <asp:DynamicValidator runat="server" ID="DynamicValidator5" ControlToValidate="dvPartnerDetails" Display="None" EnableClientScript="true" />
             <h4>Partner details:</h4>

            <asp:DetailsView ID="dvPartnerDetails" runat="server" CssClass="detailstable" FieldHeaderStyle-CssClass="bold" AutoGenerateRows="false" DefaultMode="ReadOnly" EnableModelValidation="true" OnDataBound="dvPartnerDetails_DataBound" DataSourceID="dsPartnerDetails" DataKeyNames="PersonID">
                <Fields>
                    <asp:DynamicField DataField="PartnerTitle" />
                    <asp:DynamicField DataField="PartnerForenames" />
                    <asp:DynamicField DataField="PartnerInitials" />
                    <asp:DynamicField DataField="PartnerSurname" />
                    <asp:DynamicField DataField="PartnerAddressee" />
                    <asp:DynamicField DataField="PartnerSalutation" />
                </Fields>
                <FieldHeaderStyle CssClass="bold" />
                <FooterTemplate>
                    <div class="bottomhyperlink">
                        <asp:LinkButton ID="EditHyperLink" CausesValidation="false" CssClass="btn btn-default" runat="server" CommandName="Edit">Edit</asp:LinkButton>
                        <asp:LinkButton ID="DeleteButton" runat="server" CssClass="btn btn-default" CausesValidation="false" CommandName="Delete" OnClientClick='return confirm("Are you sure you want to delete this record?");' Text="Delete" />
                    </div>
                </FooterTemplate>
            </asp:DetailsView>
        </div>
    </div>
</div>
U r s u s
  • 6,680
  • 12
  • 50
  • 88

3 Answers3

1

The problem is updatepanel always brings the original code, you need to reopen the accordion.

<script type='text/javascript'>
    $(document).ready(function() {
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);
    });

    function endRequestHandler(sender, args)
    {
        $('#collapseTwo').collapse.in()
    }
</script>
Paulo Segundo
  • 448
  • 3
  • 6
1

This may be helpful to someone else.

The proper way of achieving the desired effect is as follows:

<script type='text/javascript'>
        $(document).ready(function() {
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);
        });

        function endRequestHandler(sender, args)
        {
         $('#collapseTwo').addClass('in');
        }
</script>
U r s u s
  • 6,680
  • 12
  • 50
  • 88
0

This solution works, but I needed a more flexible solution that didn't assume which accordion was open. See my solution posted in another question:

https://stackoverflow.com/a/36363024/4047526

Community
  • 1
  • 1
dshapiro
  • 376
  • 2
  • 12