How to force closing jQuery UI accordion <DIV> using the <asp: button> button?

I am using jQuery UI accordion with two divs. The first shows the form, and the second shows the data based on the input of the form. How to automatically close the first div and display the second when the user clicks the submit button on the form? I suppose I need to use "onclick" in the button, but I'm not sure how to associate it with the accordion.

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script type="text/jscript">
$(document).ready(function () {
$("#accordion").accordion();
});
</script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<div id="accordion">
<a href="#">Criteria</a>
<div>
<asp:Button ID="Button_GetReport" runat="server" Text="View Report" />
</div>
<a href="#">Report</a>
<div>
A databound grid goes here.
</div>
</div>
</asp:Content>

If I don't get out, let me know. Thanks in advance for your help!

+3
source share
1 answer

By clicking the submit button, you will be redirected to the server, so onclick will not help you. You will probably want to deduce whether to open or close the accordion.

- div, , :

<div id="accordion" class="accordion-<%= accordion_state %>"> //open or closed

:

$(document).ready(function () {
  $(".accordion_open").accordion();
  $(".accordion_closed").hide();
});

. ASP.NET .

+1

All Articles