How can I build a tabbed menu in ASP.NET MVC?

Create View Model: public class UserViewModel { public myApplication.Models. User User; public string PartialViewName; public PartialViewModelBase Tab; } Create View Models for each Tab, derived from PartialViewModelBase: public abstract class PartialViewModelBase { } public class Tab1PartialViewModel : PartialViewModelBase { ... } public class TabNPartialViewModel : PartialViewModelBase { ... } Then make your View and PartialViews strongly typed: View: %@ Page Language="C#" MasterPageFile="~/Views/Shared/Site. Master" Inherits="System.Web.Mvc.

ViewPage" % PartialViews: %@ Control Language="C#" Inherits="System.Web.Mvc. ViewUserControl" %> " % Then in your View you can use your Partial Views as: % Html. RenderPartial(Model.

PartialViewName, Model. Tab); % In your controller action: public ActionResult YourAction(string tab) { // check if tab is valid! Var model = new UserViewModel { User = new myApplication.Models.User(); PartialViewName = tab; Tab = TabRepository.

GetTabByName(tab); /* * or * Tabs = (new Dictionary { * {"Tab1", typeof(Tab1PartialViewName)}, * {"TabN", typeof(TabNPartialViewName)} * })tab; */ }; Return View(model); } Hope this helps.

Create View Model: public class UserViewModel { public myApplication.Models. User User; public string PartialViewName; public PartialViewModelBase Tab; } Create View Models for each Tab, derived from PartialViewModelBase: public abstract class PartialViewModelBase { } public class Tab1PartialViewModel : PartialViewModelBase { ... } public class TabNPartialViewModel : PartialViewModelBase { ... } Then make your View and PartialViews strongly typed: View: " %> PartialViews: " %> " %> Then in your View you can use your Partial Views as: In your controller action: public ActionResult YourAction(string tab) { // check if tab is valid! Var model = new UserViewModel { User = new myApplication.Models.User(); PartialViewName = tab; Tab = TabRepository.

GetTabByName(tab); /* * or * Tabs = (new Dictionary { * {"Tab1", typeof(Tab1PartialViewName)}, * {"TabN", typeof(TabNPartialViewName)} * })tab; */ }; Return View(model); } Hope this helps.

This seems to be a great way to deal with my problem. But what about the class PartialViewModelBase? Is it a class that I have to create?TabRepository.

GetTabByName(tab); have to return a PartialViewModelBase. How can I do this? – Flesym Jun 10 '09 at 21:30 PartialViewModelBase is just a base class for your PartialViewModels.It could be just an empty abstract class.

TabRepository is only for example. You could just create Dictionary TabTypes = new { {"Tab1", typeof(Tab1ViewModel)}, ... }; somewhere in your controller and then do: Tab = Activator. CreateInstance(TabTypestab); – eu-ge-ne Jun 10 '09 at 21:37.

Another solution would be to create a custom route (Derive from RouteBase) that uses the querystring to select a different action. Each action would have a separate view that uses a master page containing the common content for the page. Basically you'd have "UsersController" with actions "stats", "prefs", etc.All chosen by a custom route class that you've implemented.

From the looks of it, none of the tabs seem to reveal anything without firing off the link and looking at the HTML for it, it just seems they are styled to look like how they look and just pass specific query string values. To achieve what you seem to be after you would need to grab the specified query string value if there is one and then sort your resulting data accordingly.

They are likely using the jquery ui tabs: docs.jquery.com/UI/Tabs.

I'd be surprised, the JQuery UI tabs are all-client. – erikkallen Jun 11 '09 at 22:14 no they are not, there is an option to load them via ajax: docs.jquery. Com/UI/Tabs#option-ajaxOptions – Joel Martinez Jun 12 '09 at 1:32 Yes, but they won't postback when you click them, they'll use XmlHttpRequest – erikkallen Jun 15 '09 at 9:49.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions