Register | Login
Friday, July 04, 2008

Sections
  
About Us
  
Hosting Provided by Server Intellect
Partners
Downloads
  
 WWWCoder.com Resource Directory

 

ORDER TODAY!
Professional DotNetNuke ASP.NET Portals
Amazon.com now has the only DotNetNuke book you'll ever need. Written by the guys who brought you DotNetNuke, Shaun Walker, Patrick Santry, Joe Brinkman, Dan Caron, Scott McCulloch, Scott Willhite, and Bruce Hopkins. Order it now! .

Developing Custom Applications with DotNetNuke
2/5/2006 10:28:50 PM

In this article I am going to show how, as a .net developer, you can use any .NET language to create custom applications using the DotNetNuke framework by accessing the two basic necessities in any custom application: username and role.

The majority of custom applications require security with users, roles, etc. well DotNetNuke is the perfect structure for writing custom applications. Why? you say, well Imagine having a tool which will allow for forms, windows, or LDAP authentication and an impeccable infrastructure for roles/groups allowing module-level security, that's right, not just page level but module level security. Also, DotNetNuke 4 supports ASP.NET 1.1 and 2.0 so you can easily re-use your code without re-inventing the wheel.

In this article I am going to show how, as a .net developer, you can use any .NET language to create custom applications using the DotNetNuke framework by accessing the two basic necessities in any custom application: username and role.

Assumptions:

You know how to create user controls in ASP.NET 2.0 and/or 1.1

Resources:

Article:

Step1. Create a UserControl in your project/website:

Step2. Add a Label to the UserControl:

Step 2a. Add a Reference to the “DotNetNuke.dll”

Step3. Now copy and paste this code into your usercontrols Page_Load Procedure (this is in VB.NET)

        Dim mRoles As New DotNetNuke.Entities.Users.OnlineUserInfo
        Dim mUserRoles As New DotNetNuke.Security.Roles.RoleController
        Dim mUser As DotNetNuke.Entities.Users.UserInfo = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo 

        Dim showroles As String = ""
        For Each i As String In mUserRoles.GetRolesByUser(mUser.UserID, mRoles.PortalID)
            showroles += i.ToString() & ","
        Next
 

        Me.Label1.Text = "UserName: " & mUser.Username
        Me.Label1.Text += "<br> FullName: " & mUser.FullName
        Me.Label1.Text += "<br> UserID: " & mRoles.UserID.ToString

        Me.Label1.Text += "<br> Roles:  " & showroles 

Step5. Load SmartDNNModule into your portal (follow the instructions that comes with smartdnnmodule)

Step6. Add SmartDNNModule onto a Page

Step7. In the Two Text Boxes type in: “WebUserControl.ascx” then click “Create Module”

Step8. Login in as a user

Step9. Click on the page where you loaded SmartDNNModule

Step10. You now know how to access everything to create a custom application (by exploring the classes that I have shown, you will reveal many useful functions and procedures in the DotNetNuke framework): 

About the Author:

Charles Stratton has been programming since 1999 and enjoys staying on the edge of technology. his skills range from DNN to Sharepoint to Custom Development. currently working in VB.Net and C#.Net web and software. KISS - Programmers work smarter not harder. Charles can be reached at stratcr@peoplepc.com.


Page Options:
format for printing  Format for Printer
email article  Email Page
add to your favorites   Add to Favorites
How would you rate the quality of this content?
Poor - - Excellent
Comments?
Overall Rating:
Comments Left:
Left on 12/7/2007 3:17:21 AM by Anonymous
Comments:
Left on 7/27/2007 7:20:40 AM by Anonymous
Comments: Excellent, I have been searching for the logic on how to get the current user role and I find it only here .. great work
Left on 5/21/2006 11:35:34 PM by Anonymous
Comments: you don't have to buid a dal in an ascx file. that's the point you can do what you want it flexible...
Left on 5/3/2006 4:50:35 PM by Anonymous
Comments: Its not intneded to show how to build a DAL, just how to access the user and role classes in the DNN framework. Ther are plenty of custom module DAL examples out in the world
No ratings available.
Left on 4/28/2006 1:34:56 PM by Anonymous
Comments: If you don't want to buy this SmartDNNModule just do that: do the same thing he explained in a aspx page and call this page from an IFrame module. It works great!
No ratings available.
Left on 4/13/2006 10:49:08 PM by Anonymous
Comments: good code. thanks
mjwhite
Left on 3/28/2006 9:43:19 AM by Anonymous
Comments: Seems more like an advertisement for smartmodule than anything else.
No ratings available.
Left on 3/16/2006 9:16:47 AM by Anonymous
Comments: For the comment below a DAL is not needed or a requirement for DNN. Any user control, or ASP.NET application can be converted over to DNN simply by changing where the class inherits from. Instead of the System.Web.UI.Page it inherits from the base class of DNN.
No ratings available.
Left on 3/15/2006 3:12:10 PM by Anonymous
Comments: Dim mRoles As New DotNetNuke.Entities.Users.OnlineUserInfo
        Dim mUserRoles As New DotNetNuke.Security.Roles.RoleController
        Dim mUser As DotNetNuke.Entities.Users.UserInfo = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo

        Dim showroles As String = ""
        For Each i As String In mUserRoles.GetRolesByUser(mUser.UserID, mRoles.PortalID)
            showroles += i.ToString() & ","
        Next

        Me.Label1.Text = "UserName: " & mUser.Username
        Me.Label1.Text += "
FullName: " & mUser.FullName
        Me.Label1.Text += "
UserID: " & mRoles.UserID.ToString
        Me.Label1.Text += "
Roles:  " & showroles

Left on 3/14/2006 11:09:28 AM by Anonymous
Comments: Isn't the point of these types of articles to show how to code? If I wanted to buy a module I'd go to snowcovered and look for it there.
Left on 2/16/2006 11:21:22 AM by Anonymous
Comments: That's the point. This is not a dnn module. you don't have to build a DAL. you do what ever you want. if you want to do DAL's do a custom module.
stratcr
No ratings available.
Left on 2/16/2006 8:54:03 AM by Anonymous
Comments: Basically good idea, but does not show how to build DAL code with provider model that is requirement to almost any DNN -module.
  

 Latest Articles
  

 Latest News
  

 

Spotlight
Syndication

 


 


Digg This
 


DotNetNuke Platinum Benefactor

  
 

 Terms Of Use | Privacy Statement
 Copyright 2008 - Santry Technology Solutions, Box 172, Girard, PA 16417, (814) 774-0970