Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

$4.95 Windows Hosting at Webhost4life.com
  Ads  
Engage Software - Training Partner for DotNetNuke
 


  Sponsors  

Meet Our Sponsors

ExactTarget email software solutions
Merak Mail Server
WebSecureStores -- ASP.NET & DotNetNuke Hosting Solutions
FCKeditor Project
Salaro -- Skins and more
OnyakTech
 


DotNetNuke Forums
 
  Forum  DotNetNuke® Pro...  ClientAPI Compo...  Example: Treeview and Roles
Previous Previous
 
Next Next
New Post 2/28/2007 3:26 PM
User is offline ech01
631 posts
7th Ranked




Example: Treeview and Roles 
Modified By ech01  on 2/28/2007 6:34:10 PM)

After reading Michael Washington's Tutorial I decided to do some experimenting with the DNN Web Controls, namely the DNN Tree. I came up with a way to bind all the roles in a portal and the users within that role as child items. Then when you click on the user, a small postback is done and passes the userid to a label control. From there you could do anything, like load the user's whole profile. I hope this helps some people out, and feel free to postback any contributions.

- RoleName
   -DisplayName
   -DisplayName

ASCX

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="Testing1.ascx.vb" Inherits="My.Modules.TestingControls.Testing1" %>
<%@ Register Assembly="DotNetNuke.WebControls" Namespace="DotNetNuke.UI.WebControls"
TagPrefix="DNN" %>

<table border="0" cellpadding="3" cellspacing="0">
<tr>
<td valign="top">

<DNN:DnnTree ID="MyDNNTree" runat="server" CollapsedNodeImage="../../../Images/Plus.gif"
ExpandedNodeImage="../../../Images/Minus.gif">

</DNN:DnnTree>
</td>
<td valign="top">
<asp:Label ID="lblUserId" runat="server" Text="Label"></asp:Label>&nbsp;</td>
</tr>
</table>

Code Behind

Imports DotNetNuke
Imports System.Web.UI
Imports System.Collections.Generic
Imports System.Reflection
Imports DotNetNuke.Security.PortalSecurity
Imports DotNetNuke.UI.WebControls

Namespace My.Modules.TestingControls

Partial Class Testing1

Inherits Entities.Modules.PortalModuleBase

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
MyDNNTree.ImageList.Add("../../../Images/folder.gif")
MyDNNTree.ImageList.Add("../../../Images/file.gif")
PopulateRoleTree()
End If
End Sub

Protected Sub MyDNNTree_PopulateOnDemand(ByVal source As Object, ByVal e As DotNetNuke.UI.WebControls.DNNTreeEventArgs) Handles MyDNNTree.PopulateOnDemand
PopulateChildrenTreeNodes(e.Node)
End Sub

Protected Sub MyDNNTree_NodeClick(ByVal source As Object, ByVal e As DotNetNuke.UI.WebControls.DNNTreeNodeClickEventArgs) Handles MyDNNTree.NodeClick
BindUserDetails(e.Node)
End Sub

Private Sub PopulateRoleTree()

MyDNNTree.TreeNodes.Clear()
Dim index As Integer = 0

'Get the roles for this portal
Dim arrRoles As ArrayList = DotNetNuke.Security.Membership.DNNRoleProvider.Instance().GetRoles(PortalId)

'Loop through the array of roles and add each one as a tree node
For Each role As DotNetNuke.Security.Roles.RoleInfo In arrRoles
Dim objNode As TreeNode = New TreeNode(role.RoleName)
objNode.HasNodes = True
objNode.ClickAction = eClickAction.Expand
MyDNNTree.TreeNodes.Add(objNode)
index += 1
Next

End Sub

Private Sub PopulateChildrenTreeNodes(ByVal objParent As TreeNode)

'Get an array of the Users within a role. The role is objParent.text
Dim arrUsers As ArrayList = DotNetNuke.Security.Membership.DNNRoleProvider.Instance().GetUsersByRoleName(PortalId, objParent.Text)
If arrUsers.Count > 0 Then
'Loop through the User array and add each user as a node
For Each user As DotNetNuke.Entities.Users.UserInfo In arrUsers

Dim index As Integer = 0
Dim objTreeNode As TreeNode

index = objParent.TreeNodes.Add()
objTreeNode = objParent.TreeNodes(index)
objTreeNode.Key = user.UserID 'We'll use the key to hold the userId
objTreeNode.Text = user.DisplayName
objTreeNode.ImageIndex = eImageType.Page
objTreeNode.ClickAction = eClickAction.PostBack

index += 1

Next

End If
End Sub
Private Sub BindUserDetails(ByVal objParent As TreeNode)

lblUserId.Text = objParent.Key.ToString

End Sub

Public Enum eImageType
Folder
Page
End Enum

End Class
End Namespace


www.blackhawksurfaces.com | www.nlsales.com | www.midwestfilmandvideo.com
 
Previous Previous
 
Next Next
  Forum  DotNetNuke® Pro...  ClientAPI Compo...  Example: Treeview and Roles
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, 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 DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


Convert Visitors to Customers
In order to bring value to your users, we must first understand them. VIVIDSITES will help you build a custom web application and interactive marketing tools that your users will thank you for. We marry high-end creative with head banging technology to entertain and convert visitors into paying customers. Call 314.514.0505 or visit us at http://www.vividsites.com to find out how.
- V I V I D S I T E S -
Gearworx Web Hosting
As a premier provider of Web Hosting, Private/White Label hosting, Server Colocation, Dedicated Server, and other Managed Services, Gearworx offers an array of services designed to more effectively manage strategies driving businesses on the Web. Headquartered in Fremont, California our state of the art tier one data centers and distributed managed services environment enables Gearworx to offer your business enterprise level solutions through simplified processes.
Gearworx Web Hosting
Glanton: Enterprise Intranet Specialists Using DNN
Glanton Solutions are a premier provider of sevices for large corporates lloking to outsource Intranet sites.
www.glanton.com

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP