How to avoid an asp:Multiview to load all the views
I have a multiview control on my page and a menu to create a tab control
<asp:Menu ID="tabMenu" Orientation="Horizontal" StaticMenuItemStyle-CssClass="tab"
StaticSelectedStyle-CssClass="selectedTab" CssClass="tabs" OnMenuItemClick="Menu1_MenuItemClick" runat="server">
</asp:Menu><asp:MultiView ID="multiViewTab" ActiveViewIndex="0" runat="server">
<asp:View ID="viewDetails" runat="server">
<uc:ViewDetails runat="server" ID="ucViewDetails" />
</asp:View>
<asp:View ID="viewJobs" runat="server">
<uc:ViewJob ID="ucViewJob" runat="server" />
</asp:View>
<asp:View ID="viewJobList" runat="server">
<uc:ViewJobList ID="ucViewJobList" runat="server" />
</as开发者_如何学编程p:View>
</asp:MultiView>
and i set the current view as follow
protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
{
int index = Int32.Parse(e.Item.Value);
if (index != 0)
{
tabMenu.FindItem("0").Selected = false;
}
multiViewTab.ActiveViewIndex = index;
}
it works well ... the only problem is that each time i click on a view all the views are loaded.while i would like to load only the one which is active
Do you know any way to avoid the loading of all the views?
What is the problem with loading all the views? If it's a performance issue, you can modify your binding (or whatever) code so it only happens if that view is visible.
By default, it doesn't. You have to use an AJAX implementation instead (with an update panel or stream the data using a web service or JQuery approach or something else); the MultiView isn't good with AJAX, or loading dynamically...
With an update panel approach, this means you load the view when selecting it, by loading the UC then via the LoadControl method. Not done it, but think it will work...
HTH.
精彩评论