The hidden field approach works well for me. With .aspx containing
<asp:HiddenField runat="server" ID="hfLastTab" Value="0" />
and js ready function containing
$("#tabs").tabs({ active: <%= hfLastTab.Value %> });
the active tab will be set in a hidden field. (What is the jQuery UI v1.9 property, "active" fka 'selected'.) The various controls that can be passed after setting hfLastTab.Value correspond to the corresponding index.
I also wanted to point to a specific tab with a URL from another page and spent a lot of time adding and trying to parse the end hash code before moving on to the querystring parameter? t = N. I am parsing this in the Page.IsPostback branch of the pageLoad (). For new page loads, we go to tab 0 if nothing is specified, or tab N if the query parameter has a parameter. Many ways to handle this parsing. Here is one:
if (!Page.IsPostBack) { string pat = @"t=(\d)"; Regex r = new Regex(pat, RegexOptions.IgnoreCase); Match m = r.Match(Request.Url.Query); if (m.Success) hfLastTab.Value = m.Groups[0].ToString(); }
fortboise
source share