How can i keep the selected li menu after postback

I dont speak very well english but I have some listed controls on my aspx form which is as below

here´s the menu:

<div id='cssmenu'>
            <ul>
               <li class='active'><a href=''><span>Inicio</span></a></li>
               <li class='has-sub'><a href='#'><span>Portafolio</span></a>
                  <ul>
                     <li><asp:LinkButton ID="LinkResum" runat="server" OnClick="Link_SelectedIndexChanged" 
                     Text="&nbsp;&nbsp;&nbsp;&nbsp;■ Resumen" OnClientClick="Cargar()"></asp:LinkButton></li>
                  </ul>
               </li>
               <li><asp:LinkButton ID="LinkReport" runat="server" OnClick="Link_SelectedIndexChangedReport" 
                     Text="Reporte" OnClientClick="Cargar2()"></asp:LinkButton></li>
               <li class=''><a href='#'><span>Formularios</span></a></li>
               <li><asp:LinkButton ID="LinkButton1" runat="server" OnClick="Link_SelectedIndexChangedContacto" 
                     Text="Contacto" OnClientClick="Cargar3()"></asp:LinkButton></li>
               <li class=''><a href="Javascript:__doPostBack('dnn$dnnLOGIN$cmdLogin','')"><span>Cerrar sesion</span></a></li>
            </ul>
         </div>

And my jquery is this

here´s my script:

<script type="text/javascript">

$(document).ready(function() {
    $('#cssmenu ul ul li:odd').addClass('odd');
    $('#cssmenu ul ul li:even').addClass('even');
    $('#cssmenu > ul > li > a').click(function() {
        $('#cssmenu li').removeClass('active');
        $(this).closest('li').addClass('active');
        var checkElement = $(this).next();
        if ((checkElement.is('ul')) && (checkElement.is(':visible'))) {
            $(this).closest('li').removeClass('active');
            checkElement.slideUp('normal');
        }
        if ((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
            $('#cssmenu ul ul:visible').slideUp('normal');
            checkElement.slideDown('normal');
        }
        if ($(this).closest('li').find('ul').children().length == 0) {
            return true;
        } else {
            return false;
        }
    });
});

I want to keep the selected li after postback, im not good jquery programmer...

thank you.

Answers


Save this files as index.html then click the menu item use alert function for debug

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">


    <head>
        <title>Accordion test</title>
        <script type="text/javascript" src="http://ajax.googleapis.centercodehereom/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function () {

                // initialize accordion
                $('#Accordion ul').each(function () {
                    alert(currentURI);
                    var currentURI = window.location.href;
                    var links = $('a', this);
                    var collapse = true;
                    alert(links.size());
                    for (var i = 0; i < links.size() ; i++) {
                        var elem = links.eq(i);
                        var href = elem.attr('href');
                        var hrefLength = href.length;
                        var compareTo = currentURI.substr(-1 * hrefLength);


                        if (href == compareTo) {
                            alert(href);
                            collapse = false;
                            break;
                        }
                    };
                    if (collapse) {
                        $(this).hide();
                    }
                });

                // on click, show this element and hide all others
                $('#Accordion > li').click(function () {
                    var me = $(this).children('ul');
                    $('#Accordion ul').not(me).slideUp();
                    me.slideDown();
                });
            });
        </script>
</html>
<body>
    <ul id="Accordion">
        <li>
            PEOPLE
            <ul>
                <li><strong>+</strong> <a href="index.html?show=Yousuf&Ali">Yousuf Ali</a></li>
                <li><strong>+</strong> <a href="index.html?show=hanifa">HANIFA</a></li>            
                <li><strong>+</strong> <a href="index.html?show=Mohamed">MOHAMED</a></li>

            </ul>
        </li>
        <li>
            EVENTS
            <ul>
                <li><strong>+</strong> <a  href="index.html?show=Khaja&Mohideen">COMING SOON</a></li>
            </ul>
        </li>
        <li>
            LANDSCAPES
            <ul>
                <li><strong>+</strong> <a  href="index.html?show=Askar&Ali">COMING SOON</a></li>
            </ul>
        </li>
        <li>
            INFO
            <ul>
                <li><strong>+</strong> <a  href="index.html?show=Mohideen&Ali">COMING SOON</a></li>
            </ul>
        </li>
    </ul>
</body>
</html>

Need Your Help

Interpolation using armadillo

c++ interpolation armadillo

So it appears as though armadillo does not have any interpolation capability (at least I can find no reference to it in the documentation). I was wondering if anyone has any suggestions on how best...

Objective-c animation block doesn't seem to fire

iphone objective-c xcode animation uiview

I have a method in my UIView subclass "Card" to dismiss an instance by fading its alpha from 1 to 0. I do a similar thing when I add the card to the superview and it fades in fine. But when I call