jQuery Tabs
While the TabControl provided by Microsoft in the AJAX toolkit is probably a bit easier to use, the Tabs in jQuery are not much harder to implement and give us a bit more flexibility.
Here are the steps to implement:
First, make sure the HTML (ASPX) page you are creating is pointing at the stylesheet that contains the jQuery UI theme you are using. The tabs make use of the themes and will not render as tabs unless the styles are pulled in.
Next you’ll need to create the HTML. Everything that has to do with tabs should be wrapped in a DIV. You can either give the ID a class or give it an ID, as long as you can select it later to apply the tabs() method that turns it all into a tabbed interface.
Within that DIV, you’ll place an unordered list:
<ul> <li><a href="#firstTab">First</a></li> <li><a href="#secondTab">Second</a></li> <li><a href="#thirdTab">Third</a></li> <li><a href="#forthTab">Forth</a></li> </ul>
which represents your tabs. Notice the href=”#id” stuff. Those are pointing to ids of the DIVS that come next.
<div id="firstTab">first content</div> <div id="secondTab">second content</div> <div id="thirdTab">Third content</div> <div id="forthTab">Forth content</div>
Next, in your jQuery code, select the outer DIV and call tabs()
$(function() { $("#tabs").tabs(); });
There are a ton of options for the tab control that would take several posts to cover, but I do want to point out just a few.
First, you can add tabs on the fly and remove them on the fly using the add() and remove() methods.
Second, you can load the tab’s content on the fly by using a real URL in the href, specifying a title tag and creating a similar ID for the DIV that represents the content area (spaces are replaced with underscores). If you do this you can also pass in an option that tells it to cache the retrieved content or go after it every time the tab is requested.
Finally, you can easily enable and disable tabs by calling tabs() again with tabs(‘enable’,tabIndex) or tabs(‘disable’,tabIndex)
For the full documentation, see http://jqueryui.com/demos/tabs/
Other post in jQuery
- jQuery - The Man, The Myth, The Legend - October 8th, 2008
- Getting started with jQuery and ASP.NET - October 15th, 2008
- jQuery - Explaining Last Week's Code - October 21st, 2008
- Friday Books - "Learning jQuery" - October 24th, 2008
- jQuery Simple Selectors - October 28th, 2008
- Friday Books - "jQuery in Action" - October 31st, 2008
- jQuery Selectors - Looks just like CSS - November 6th, 2008
- VS2008 SP1 Hotfix to Support "-vsdoc.js" IntelliSense Doc Files - November 11th, 2008
- jQuery Looks like XPath - November 12th, 2008
- jQuery - class manipulation - November 19th, 2008
- jQuery - Events - December 2nd, 2008
- Host jQuery at Google (with Intellisense support) - December 10th, 2008
- jQuery - Calling Your Own Functions - December 16th, 2008
- Friday Books - jQuery Reference Guide - December 19th, 2008
- jQuery - Creating Plug-ins - December 23rd, 2008
- jQuery - Loading Partial Content - December 30th, 2008
- jQuery - Positioning Elements - January 6th, 2009
- AjaxToolKit TabControl Disabled Tab - January 12th, 2009
- jQuery, JSON, and ASP.NET - January 15th, 2009
- Review of the MDC at NYC - January 21st, 2009
- jQuery - Retrieving HTML Fragments - January 22nd, 2009
- jQuery GUI - Drag - February 3rd, 2009
- jQuery - Drop - February 12th, 2009
- jQuery UI - Resizable w/ ASP.NET Themes - February 18th, 2009
- jQuery, bgiframe and IE6 z-order hacks - February 19th, 2009
- jQuery - Sliders (scrollbars to the rest of us) - March 4th, 2009
- jQuery - Using Slider as a Scrollbar - March 12th, 2009
- jQuery - Auto Scrolling the Slider - March 23rd, 2009
- Live Presentation of jQuery - March 23rd, 2009
- Just a Week Away! - April 7th, 2009
- jQuery Tabs - April 9th, 2009
- jQuery Demos From Last Tuesday’s Presentation - April 16th, 2009
- jQuery – Accordion - May 6th, 2009
- CustomValidationControl and jQuery - May 11th, 2009
- Mixing ASP.NET, jQuery and JSON - May 12th, 2009
- jQuery Progressbar - May 20th, 2009
- jQuery – Dialog - June 2nd, 2009
- jQuery – Modal Dialog - June 9th, 2009
- Does jQuery Make Us Lazy? - June 18th, 2009
- jQuery Dialog – With Validation Controls - June 25th, 2009
- jQuery – Date Picker - July 2nd, 2009
- jQuery Splitter - July 21st, 2009
- jQuery Expand/Collapse Using Head Tags - October 15th, 2009
- Do you Need My Help? - November 18th, 2009
- Flash to jQuery - November 30th, 2009
- JQuery, Cufon, and Dynamic Content - December 1st, 2009
- jQuery, Each() and Async Gets - December 2nd, 2009
- jQuery and ASP.NET UpdatePanel - January 6th, 2010
- jQuery 1.4 Released - January 15th, 2010
Other Related Items:
National Electrical Code 2008 Index TabsUser-friendly and up-to-date, these National Electrical Code®Tabs are a great way to organize the NEC® 2008. These self-adhesive tabs can reduc... Read More >
Londons Times Funny Food Coffee other Digestibles - Javascript - Light Switch Covers - double toggle switchJavascript Light Switch Cover is new and handcrafted utilizing unique process resulting in a stunning high gloss ceramic-like finish. SET OF MATCHING SCREWS IS INCLUDED giving it a perfect finishing touch. Made of durable metal material.










[...] .NET Answers, Dave: jQuery Tabs [...]