In theory, the cookie should be set each time you select a tab. All my forms are being submitted via ajax, so I'm simply doing a refresh if the response is good, so that might exhibit different behaviour than a normal post.

David


Paul Allington wrote:
There is a chance this could work perhaps. I've added the cookie plugin, which seems to work partly, but not on the postback. The postback doesn't appear to save the cookie data, it just reverts to the initial state that was initially loaded from the cookie.

<%@ Page Language="C#" AutoEventWireup="true"  %>

<script type="text/C#" runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
ScriptManager.RegisterClientScriptBlock(this, GetType(), "SetupTabs", @"$(document).ready(function() { $(""div.pageTabs"").tabs({ cookie: { expires: 30 } });
                });", true);
    }
protected void DummyCall(object sender, EventArgs e)
    {
        // Do nothing
    }
</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

<html xmlns="http://www.w3.org/1999/xhtml"; >
<head runat="server">
    <title></title>
<script type="text/javascript" src="http://ui.jquery.com/testing/jquery-1.3.1.js";></script> <script type="text/javascript" src="http://ui.jquery.com/testing/ui/ui.core.js";></script> <script type="text/javascript" src="http://ui.jquery.com/testing/ui/ui.tabs.js";></script>
    <script tyep="text/javascript" src="jquery/jquery.cookie.js"></script>
<style type="text/css">
        .ui-tabs .ui-tabs-hide {
             display: none;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager runat="server"></asp:ScriptManager>
        <asp:UpdatePanel runat="server">
            <ContentTemplate>
                <div class="pageTabs">
<ul> <li><a href="#Tab1">Tab 1</a></li>
                        <li><a href="#Tab2">Tab 2</a></li>
                        <li><a href="#Tab3">Tab 3</a></li>
                        <li><a href="#Tab4">Tab 4</a></li>
</ul> <div id="Tab1">
                        <h1>Tab 1</h1>
                    </div>
                    <div id="Tab2">
                        <h1>Tab 2</h1>
<asp:Button runat="server" ID="DummyButton" Text="Click Me" OnClick="DummyCall" />
                    </div>
                    <div id="Tab3">
                        <h1>Tab 3</h1>
                    </div>
                    <div id="Tab4">
                        <h1>Tab 4</h1>
                    </div>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </form>
</body>
</html>


2009/2/25 David Muir <davidkm...@gmail.com <mailto:davidkm...@gmail.com>>

    It requires the cookie plugin.
    David


    Paul Allington wrote:
    Would the cookies option help in this case? I've come across the
    cookies option but I haven't been able to make it work (I don't
    know when it saves the cookie).

    P


    2009/2/25 David Muir <davidkm...@gmail.com
    <mailto:davidkm...@gmail.com>>


        I think what P is referring to is what using cookies enables:
        remember what tab you were on when refreshing the page.

        Which makes me wonder, why not have an option to have the
        hash set instead of using a cookie?

        eg
        index.html:

        <div class="tabs">
          <ul>
              <li><a href="#tab1">Tab1</a></li>
              <li><a href="#tab2">Tab2</a></li>
          </ul>
          <div id="tab1"></div>
          <div id="tab2"></div>
        </div>

        If I type index.html#tab2 in the address bar, it loads the
        page with tab2 selected. Which is great, as it lets me jump
        to a specific tab from a different page, and refreshing the
        page means that tab2 stays selected.
        Currently we need to use a separate plugin to handle this.
        Looking through the source, it says that the hash is being
        stripped from the url until issue #3808 is fixed. Just
        checked and 3808 has been fixed, so does that mean we can
        have our hashes again? :-)

        Cheers,
        David


        Klaus Hartl wrote:

            You're giving way too less information to answer the
            question if this
            has been sorted out. Maybe it needs to be sorted out in
            your own code.

            Please provide a pastebin or test page.

            --Klaus



            On 25 Feb., 11:22, Intelligent Penguin
            <phalling...@googlemail.com
            <mailto:phalling...@googlemail.com>>
            wrote:
                Hello

                I've got some of the UI/Tabs (which are very nice,
                really like them)
                on a page that is encased in an UpdatePanel.  On
                doing a partial
                postback, the selected tab reverts to it's initial
                state (ie, if I do
                a partial postback from tab #2, it reverts to
                displaying tab #1).

                Has this been sorted already?

                Many thanks, P





Reply via email to