Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesdnnTabs - Programmatically select a tab?dnnTabs - Programmatically select a tab?
Previous
 
Next
New Post
9/16/2011 9:42 AM
 
I am in the process of converting a large module into the DNN6 form patterns, including making use of dnnTabs and dnnPanels. I like that the dnnTabs automatically remembers the previously selected tab when you return to that page, but I have a case where based on different circumstances I need to programatically select a tab to be selected. Is there an easy way to do this?
 
New Post
9/24/2011 3:45 PM
 
AFAIK the tabs can be navigated to by using the #tabname notation so you just need to add that to the url

Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
10/27/2011 11:22 AM
 
I solved this problem, so I thought I should come back and post my solution for anyone else trying to do the same thing.

The selected tab is actually stored in a cookie, so all you have to do is create a new cookie with the same name and then set your desired new value. I used Firebug to find the name of the cookie being created (in my case it was "dnnTabs-emsEditRegistrant" with emsEditRegistrant being the css selector class I used to create the tabs to begin with). I have code coming from one page that targets the page with the tabs, and also passes a value in the query string called TabFocus that tells me to override the default focus and set a new one. My code looks like:

if (Request.QueryString["TabFocus"] != null)
{
  HttpCookie myCookie = new HttpCookie("dnnTabs-emsEditRegistrant");
  myCookie.HttpOnly = false;
  switch (Request.QueryString["TabFocus"])
  {
    case "Hotel":
      myCookie.Value = "2";
      break;

    case "Invoice":
      myCookie.Value = "5";
      break;

    case "CardsOnFile":
      myCookie.Value = "8";
      break;
   }
  Response.Cookies.Add(myCookie);
}

So basically on my Page_Load() method I check the query string if I need to focus a specific tab, and if so create a new cookie with the same name as the existing one I am replacing (you can't edit a cookie, all you can do is overwrite it with a new cookie of the same name). It is very important to set the HttpOnly property on the cookie to False, otherwise the client script will not be able to read the cookie and you will be stuck on the first tab forever. The numbering for the tabs is a zero-based count.

In my real production code I have replaced the magic numbers for the tabs with a Enum so that they will mean something to future developers, but the code above gives the basic idea.
 
New Post
10/28/2011 1:20 PM
 
thanks for posting back - im sure there are a few ways to do this but that seems a nice solution that others can use.

Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
2/2/2012 4:16 AM
 
This solution worked well for me when using dnnTabs inside a modal popup window.

Thanks,
Ries
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesdnnTabs - Programmatically select a tab?dnnTabs - Programmatically select a tab?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out