Monday, December 01, 2008 Login    Register

 


  Search Blog  
  Blog Listing  
  Blog Archive  
DNN Standard
  HOW TO: Get DNN TabInfo (page) object from TabId  
Location: BlogsThe Mighty Blog    
Posted by: Will Strohl 6/26/2007
In DotNetNuke, you generally are always working with the tab (page) that you are currently on whether it be at the module level or not. However, on occassion, you might need to access the properties of another tab (page) that you are not currently on.

In DotNetNuke (DNN), you generally are always working with the tab (page) that you are currently on whether it be at the module level or not.  However, on occassion, you might need to access the properties of another tab (page) that you are not currently on.

The DotNetNuke core framework does an absolutely wonderful job of exposing the most commonly needed page, site, and module properties when you are dealing with its programmatic elements, namely module development.  However, we are not always programming within the module scope.  Sometimes, you might be creating a customer provider or custom class to deal with some Business Logic Layer (BLL).

It is during these aforementioned times that we very often need to access certain properties of OTHER tabs when we are not on those tabs.  Here is a method that could very well be of help to you (with overloads):

''' <summary>
''' GetTabInfoByTabId - this method allows you to easily get an instance of a specific tab that you are looking for in the portal using its TabId
''' </summary>
''' <param name="intTabId">Integer - the id number of the tab</param>
''' <returns>DotNetNuke.Entities.Tabs.TabInfo - the object that holds all of the information about a tab</returns>
''' <remarks>
''' This method uses the DesktopTabs collection in the PortalSettings object to locate the tab. It assumes that you intend to use the 
''' current instance of PortalSettings.
''' </remarks>
Overloads Shared Function GetTabInfoByTabId(ByVal intTabId As Integer) As DotNetNuke.Entities.Tabs.TabInfo
    Return GetTabInfoByTabId(intTabId, DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings)
End Function

''' <summary> ''' GetTabInfoByTabId - this method allows you to easily get an instance of a specific tab that you are looking for in the portal using its TabId ''' </summary> ''' <param name="intTabId">Integer - the id number of the tab</param> ''' <param> name="objPortalSettings">DotNetNuke.Entities.Portals.PortalSettings - the object that holds all of the portal settings</param> ''' <returns>DotNetNuke.Entities.Tabs.TabInfo - the object that holds all of the information about a tab</returns> ''' <remarks> ''' This method uses the DesktopTabs collection in the PortalSettings object to locate the tab. ''' </remarks> Overloads Shared Function GetTabInfoByTabId(ByVal intTabId As Integer, ByVal objPortalSettings As DotNetNuke.Entities.Portals.PortalSettings) As DotNetNuke.Entities.Tabs.TabInfo     '     ' BEGIN VALIDATION     '     ' this is using a regex expression in a custom class to check the value     If Not Utilities.RegExLibrary.IsNumber(intTabId) Then _     Throw New ArgumentNullException(" The intTabId argument must be a number")     If objPortalSettings Is Nothing Then _     Throw New ArgumentNullException(" The objPortalSettings argument cannot be null")     '     ' END VALIDATION     '     ' create a tab instance to send back     Dim tab As DotNetNuke.Entities.Tabs.TabInfo = Nothing     ' find the tab that matches the given tabid     For intIndex As Integer = 0 To objPortalSettings.DesktopTabs.Count - 1         tab = CType(objPortalSettings.DesktopTabs(intIndex), Entities.Tabs.TabInfo)         ' if the tab matches, send it back         If tab.TabID = intTabId Then Return tab     Next     ' we should hopefully never hit this return     Return tab End Function
Copyright ©2007 Will Strohl
Permalink |  Trackback

Comments (2)   Add Comment
Re: HOW TO: Get DNN TabInfo (page) object from TabId    By Kathleen Ballard on 9/12/2007
Where does this method come from?<br><br>Utilities.RegExLibrary.IsNumber(intTabId)<br><br>Thanks for this article, it was very helpful.

Re: HOW TO: Get DNN TabInfo (page) object from TabId    By wills on 9/12/2007
This is a method in a custom class of validation methods that I have built for quick and easy argument and data validation. All members use Regular Expression for ease of use, dependability, and performance. I left those lines in there simply to show you that you should be performing checks on the incoming arguments for better error handling and prevention.


Your name:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment   Cancel 
© Copyright 2004-2008 by Will Strohl. All rights reserved.