Introduction
In this article we will see how to create tabs for our ASP.Net MVC application. We will create these tabs using a j-query UI. In last article we saw creation of an accordion control for our MVC application using same j-query UI we will create tabs for our MVC application.
To do this we need an additional j-query UI plugin of which you can download from here. After downloading the UI find the scripts listed below in the UI folder.
-
jquery-1.7.1.js
- jquery.ui.core.js
- jquery.ui.widget.js
- jquery.ui.tabs.js
Now you have all the script files. You can start the work. Here we will see simple and collapsible tabs. So let's start.
Step 1:
First start a new MVC web application project and add a controller with an Index action and add the view associated with the Index action.
Step 2:
First in your view refer to the given js files and CSS in <head>section</head> like below.
<link rel="stylesheet" href="../../Content/themes/base/jquery.ui.all.css">
<script src="../../Scripts/jquery-1.7.1.js"></script>
<script src="../../Scripts/jquery.ui.core.js"></script>
<script src="../../Scripts/jquery.ui.widget.js"></script>
<script src="../../Scripts/jquery.ui.tabs.js"></script>
<link rel="stylesheet" href="../../Content/themes/base/demos.css">
<script>
$(function () { $("#tabs").tabs(); });
</script>
In the above line of code we only refer to the CSS and js files of the j-query UI with one script to pass the tab id to the tabs. The js file functions which will make our <div> as tab. The above tab is a simple tab; you can create it as collapsible by passing the collapsible=true property in the above script.

ash ashPosted Dec 26, 2014, 12:10 PM
How to create subtab?
Yogendra GuptaPosted Mar 11, 2013, 9:18 AM
Thank you...
sreekanth bantuPosted Sep 26, 2012, 3:07 AM
Thank you....this is working awesome.
Stephen JohnsonPosted Feb 2, 2012, 10:51 PM
Its a very useful and good article.