Click here to Skip to main content
13,003,388 members (57,891 online)
Click here to Skip to main content
Articles » Web Development » Ajax » Samples » Downloads


25 bookmarked
Posted 24 Sep 2010

Dynamic Generation of Tabs to Host IFrames using jQuery and Json in ASP.NET MVC

, 1 Oct 2010
This article introduces a method to dynamically generate tabs to host IFrames using jQuery and Json in ASP.NET MVC.
<%@ Page Language="C#"
    Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="TitleContent"
    ContentPlaceHolderID="TitleContent" runat="server">
    IFrame host with dynamically generated jQuery Tabs

<asp:Content ID="MainContent"
    ContentPlaceHolderID="MainContent" runat="server">

<!-- This is the place holder for the dynamically generated tabs -->
<div id="MainTabs" class="FluidContent">
    <div id="divTabs" class="iframeMax"></div>

<script type="text/javascript">
    var GetTabsUrl = '<%: Url.Action("GetTabs", "Home") %>';
    var IFrameContainerUrl = '<%: Url.Action("IFrameContainer", "Home") %>';

    $(document).ready(function () {

            cache: false,
            type: "POST",
            url: GetTabsUrl,
            dataType: "json",
            success: function (data) {
                var GenerateTabs = function () {
                    var tabui = document.createElement("ul");
                    $.each(data, function () {
                        var li = document.createElement("li");
                        var a = document.createElement("a");
                        a.href = IFrameContainerUrl + "?WebURL="
                            + escape(this.TabUrl)
                            + "&InformationText="
                            + escape(this.TabInformationText);
                        var span = document.createElement("span");
                        $(span).attr("title", this.TabInformationText);
                        var tx = document.createTextNode(this.TabText);



                    var $tabs = $("#divTabs").tabs({
                        cache: true,
                        selected: -1,
                        select: function (event, ui) {
                            return true;
                    }).ajaxComplete(function (event, request, settings) {

                    if (data.length > 0) {
                        $tabs.tabs('select', 0);

            error: function (xhr) {
                var status = xhr.status;
                var responseText = xhr.responseText;
                alert("Error occurred when load the information for the tabs");


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Dr. Song Li
United States United States
I have been working in the IT industry for some time. It is still exciting and I am still learning. I am a happy and honest person, and I want to be your friend.

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170626.1 | Last Updated 1 Oct 2010
Article Copyright 2010 by Dr. Song Li
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid