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

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Extend UserInfoExtend UserInfo
Previous
 
Next
New Post
11/4/2007 6:04 AM
 

 public class MyUserInfo : DotNetNuke.Entities.Users.UserInfo
 {

    // My Custom Properties

    public MyUserInfo() : base() { }

}

public class MyUserController : DotNetNuke.Entities.Users.UserController
{

        [DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
        public new MyUserInfo GetUser(int portalId, int userId)
        {
            DotNetNuke.Entities.Users.UserInfo user = base.GetUser(portalId, userId);  // this line returns the error
            //IDataReader dr = DataProvider.Instance().GetUser( userId);
            return (MyUserInfo)user;
        }

}

On My page I am binding a FormView via an ObjectDataSource to the GetUser method above. I get this error: Exception has been thrown by the target of an invocation.

Can some help in reviewing my code, I am trying to extend the UserInfo to add additional properties to my UserInfo. Eventually I want to be able to save the UserInfo and MyUserInfo objects.

Thanks

 
New Post
11/5/2007 8:06 AM
 

Hey Howard,

try this

        [DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
        public new MyUserInfo GetUser(int portalId, int userId)
        {

           MyUserInfo user = (MyUserInfo)base.GetUser(portalId, userId); 
           return user;

        }


Find out code snippets, tutorials and How Tos' about dotnetnuke at lakhlaniprashant.blogspot.com Umlimited wedding planning tips, free wedding websites and more at http://www.FirstPhera.com an indian dotnetnuke portal dedicated to wedding planning!
 
New Post
11/5/2007 3:31 PM
 

Prashant,

Thanks for the suggestion. I am getting the following error now:

"Unable to cast object of type 'DotNetNuke.Entities.Users.UserInfo' to type 'Company.Modules.ModuleName.MyUserInfo'."

Does any one know what could be going wrong here?

 

 

    public class MyUserInfo : DotNetNuke.Entities.Users.UserInfo
    {
        private int _userType;

        public int UserType
        {
            get { return _userType; }
            set { _userType = value; }
        }

        public MyUserInfo() : base()
        {
            //
            // TODO: Add constructor logic here
            //
        }
    }

 
New Post
11/5/2007 11:04 PM
 

Hey Howard,

      I'm Sorry I suggested wrong code without checking it.

     I was doing the same stuff before some days.  What I have done is, In place returning the UserInfo Object, We have used MyUserInfo object, That way we can directly access new properties in MyUserInfo also in all the pages. I don't know wather its suitable in your case or not, but you cannot cast base class object to derive class so I switched to the solution like that. In my case its working and may be you can also find the way through that.

Thanks & Regards.

Prashant


Find out code snippets, tutorials and How Tos' about dotnetnuke at lakhlaniprashant.blogspot.com Umlimited wedding planning tips, free wedding websites and more at http://www.FirstPhera.com an indian dotnetnuke portal dedicated to wedding planning!
 
New Post
11/6/2007 12:34 PM
 

Hi Prashant,

Can you recommend, with sample code if possible, on how to extend the UserInfo object to add more properties to it.

I want to save the additional properties to MyUserInfo object in a separate Table with a reference to UserId.

Thanks

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Extend UserInfoExtend UserInfo


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