Thursday, 11 February 2016

jQuery Accordion Menu With Sortable Effect in Asp.net

2/11/2016 - By Pranav Singh 0

In this article I will show you how you can create accordion menu using jQuery in your asp.net application. In this I have used div panel to prepare the accordion menu using css, jQuery.



   <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
    <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
    <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>


Now add the below html code for displaying the accordion menu.


<div id="accordionMenu" class="fontsize">
        <div class="group">
            <h3>Section 1</h3>
            <div>
                <p><h1>Section 1</h1></p>
            </div>
        </div>
        <div class="group">
            <h3>Section 2</h3>
            <div>
                <p><h1>Section 2</h1> </p>
            </div>
        </div>
        <div class="group">
            <h3>Section 3</h3>
            <div>
                <p><h1>Section 3</h1></p>

            </div>
        </div>
        <div class="group">
            <h3>Section 4</h3>
            <div>
                <p><h1>Section 4</h1></p>
            </div>
        </div>
        <div class="group">
            <h3>Section 5</h3>
            <div>
                <p><h1>Section 5</h1></p>
            </div>
        </div>
    </div>


Now we will use the below code to make the menu functional.


<script>
        $(function () {
            $("#accordionMenu")
              .accordion({
                  header: "> div > h3"
              })
              .sortable({
                  axis: "y",
                  handle: "h3",
                  stop: function (event, ui) {
                      ui.item.children("h3").triggerHandler("focusout");
                      $(this).accordion("refresh");
                  }
              });
        });
    </script>


Here is the complete code.

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>jQuery Accordion Menu With Sortable Effect in Asp.net</title>
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
    <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
    <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
    <style>
        /* IE has layout issues when sorting (see #5413) */
        .group {
            zoom: 1;
        }
        .fontsize{
            font-size:11px;
        }
    </style>
    <script>
        $(function () {
            $("#accordionMenu")
              .accordion({
                  header: "> div > h3"
              })
              .sortable({
                  axis: "y",
                  handle: "h3",
                  stop: function (event, ui) {
                      ui.item.children("h3").triggerHandler("focusout");
                      $(this).accordion("refresh");
                  }
              });
        });
    </script>
</head>
<body>

    <div id="accordionMenu" class="fontsize">
        <div class="group">
            <h3>Section 1</h3>
            <div>
                <p><h1>Section 1</h1></p>
            </div>
        </div>
        <div class="group">
            <h3>Section 2</h3>
            <div>
                <p><h1>Section 2</h1> </p>
            </div>
        </div>
        <div class="group">
            <h3>Section 3</h3>
            <div>
                <p><h1>Section 3</h1></p>

            </div>
        </div>
        <div class="group">
            <h3>Section 4</h3>
            <div>
                <p><h1>Section 4</h1></p>
            </div>
        </div>
        <div class="group">
            <h3>Section 5</h3>
            <div>
                <p><h1>Section 5</h1></p>
            </div>
        </div>
    </div>


</body>
</html>

Now we have done run the application to check the output.


About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top