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...DNN Platform (o...DNN Platform (o...Call External Class Methods to format Data passing DNN environment ?Call External Class Methods to format Data passing DNN environment ?
Previous
 
Next
New Post
9/20/2008 9:04 PM
 

Hi,

I want to call  a bunch of data formatting methods in an external class (method 3 below) so that I can reuse this in multiple UI displays.

I need help with method 3 in creating a static Helper class with how to pass the appropriate DNN context to the static method.

Code below will display the Email field if the user is an admininstrator and ... if he is NOT.

Method 1:

           <%#  (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName) == true ? Eval("RsvpEmail") : "...")%>


Method 2:
           <%#  DisplayEmail(Eval("RsvpEmail"))%>


// codebehind method, requires that you put this code in each User Control

public string DisplayEmail ( object oEmail )
{
// if Admin is logged in show Full Email else show ...
return ( (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName)  == true ? oEmail.ToString()  : "...");
}


Method 3:  call method in external class

This is preferable as we can abstract the Display logic to this external class
and not have UI display business rules based on security in the aspx page


           <%#  DNNRsvpUtil.DisplayEmail(Eval("RsvpEmail"), ???? )%>


public static class DNNRsvpUtil
{

 public static string DisplayEmail ( object oEmail, ??? )
 {

// this won't work until we pass the correct DNN context objects in
return ( (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName)  == true ? oEmail.ToString()  : "...");
}

}

 

Thanks, Paul

 

 

 
New Post
9/21/2008 9:40 AM
Accepted Answer 

In your Method 3 you should be able to code the following:

PortalSettings ps = PortalController.GetCurrentPortalSettings();
return ((PortalSecurity.IsInRole(ps.AdministratorRoleName) == true ? oEMail.ToString() : "...");

 


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
9/21/2008 2:05 PM
 

Hi William,

Thanks for the tip.

      PortalSettings ps = PortalController.GetCurrentPortalSettings();

I added this using to the external class:

using

DotNetNuke.Entities.Portals;

Regards, Paul

 

 
Previous
 
Next
HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Call External Class Methods to format Data passing DNN environment ?Call External Class Methods to format Data passing DNN environment ?


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