views:

26

answers:

1

I have the following markup inside a master page

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
    <link href="../../Content/jquery-ui-1.8.4.custom.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="../../Scripts/JQueryUI.js" type="text/javascript"></script>
</head>
<body>
    <div>
        <div id="tabs">
            <ul>
                <li><%=Html.TabLink("Home","Index","Home")%></li>
                <li><%=Html.TabLink("Posts","Index","Posts") %></li>
                <li><%=Html.TabLink("About", "Index", "About") %></li>
            </ul>
        </div>    
        <asp:ContentPlaceHolder ID="MainContent" runat="server">
        </asp:ContentPlaceHolder>
        <script type="text/javascript">
                $(function() {
                    $("#tabs").tabs();
                });
        </script>
    </div>
</body>
</html>

The TabLink is an extension method which renders the following markup:

<ul>
    <li><a href="/Home/Index"><span>Home</span></a></li>
    <li><a href="/Posts/Index"><span>Posts</span></a></li>
    <li><a href="/About/Index"><span>About</span></a></li>
</ul>

Each partial view (eg _index.aspx) has this markup:

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Index
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div id="tabs-1"> Hello from tab1
     </div>
</asp:Content>

jQuery tab loads each view asynchronously, however it also downloads the javascripts and css files every time a tab is clicked. And also it left the link markup there as well(meaning together w/ the jquerified tab), and doesn't work at all in IE8 and inconsistent with firefox and chrome.

Anything I missed or suggestion would be greatly appreciated.

+1  A: 

You should use partial views, but it seems you use regular views with master page.

Partial view will look like this

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<object>" %>

<div id="tabs-1"> 
    Hello from tab1
</div>
Alexander Prokofyev
I've since updated it like this. thanks
bonskijr