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 ExtensionsModulesModulesProgrammatically setting the permissions of a TabPermissionsGrid or page.Programmatically setting the permissions of a TabPermissionsGrid or page.
Previous
 
Next
New Post
4/14/2010 1:19 PM
 

I'm developing a module that will programmatically create new pages in a DNN site.  The part I'm stumped on is how to dynamically assign the permissions for the page.  I've read a few tutorials and in most cases it is recommended that you place a TabPermissionsGrid on the page and when you create the page in your code-behind just set the permissions of the page to the permissions of the grid.

Unfortunately, that's not exactly ideal for my situation since if I'm going to make the user click to choose permissions for the page then it defeats the purpose of having the page automatically created for them.  With that in my mind, it was my goal to add the grid, hide it and have the permissions set to what is needed for the page being created.  The problem is, I can't figure out how to set the permissions of the TabPermissionsGrid any better than I can set the permissions of the page I'm trying to create.

Since they both have the Permissions property and one's permission can be set to equal the other's permission without any type of casting, I'm assuming the permissions are created the same.  So basically, I need a way to do this programmatically without forcing any user input.  Any ideas?

 
New Post
4/15/2010 2:34 PM
 

My guess would be that you are looking to "copy" permissions from a specific tab to apply to the other tabs then?  if so, you could get the tabpermissions of the "Default" tab, and just apply that to the new ones that you create, bypassing the TabPermissionGrid altogether.


-Mitchel Sellers
Microsoft MVP, ASPInsider, DNN MVP
CEO/Director of Development - IowaComputerGurus Inc.
LinkedIn Profile

Visit mitchelsellers.com for my mostly DNN Blog and support forum.

Visit IowaComputerGurus.com for free DNN Modules, DNN Performance Tips, DNN Consulting Quotes, and DNN Technical Support Services
 
New Post
4/16/2010 2:16 PM
 

Mitchel,  thanks for the suggestion.  As always, it came down to such a simple solution.  I took your idea and ran with it.  There was one small problem in that each new page has one entry for it's own unique permissions, but I actually ended upf figuring out how to dynamically add permissions to a page without having to copy them from anywhere.

Thanks again.

 
New Post
8/9/2010 3:16 PM
 
Good morning Gents,

What you describe, Mitchel, used to work in some of my old code, but recently I noticed that this:

objCopyToTab.TabPermissions = objCopyFromTab.TabPermissions

causes a compiler error, "Property 'TabPermissions' is 'ReadOnly'.

So now I am trying this:
Dim conPerm As TabPermissionController
For Each infoPerm As TabPermissionInfo In objCopyFromTab.TabPermissions
  conPerm.AddTabPermission(infoPerm)
Next

I'm running this code through the debugger right now and I'll let you all know if it works.  BTW, the new code causes a compiler warning that AddTabPermission is being deprecated but a post by Sebastian Leopold indicates that there isn't a known replacement yet.

-something clever or funny.
 
New Post
8/13/2010 2:22 PM
 
Darn it.  I am getting Object Reference Exception on the code I posted on the line: conPerm.AddTabPermission(infoPerm).  That makes sense because conPerm is just a controller.  Doh.  Newb mistake.

I am trying this now (where ctrTab is my TabController):
objCopyToTab.TabPermissions.AddRange(objCopyFromTab.TabPermissions)
ctrTab.UpdateTab(objCopyToTab)

-OR-

For Each infoPerm As TabPermissionInfo In objCopyFromTab.TabPermissions
objCopyToTab.TabPermissions.Add(infoPerm)
Next
ctrTab.UpdateTab(objCopyToTab)

Both seem to work.

-something clever or funny.
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesProgrammatically setting the permissions of a TabPermissionsGrid or page.Programmatically setting the permissions of a TabPermissionsGrid or page.


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