且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在DNN中正确设置自定义配置文件属性?

更新时间:2022-10-16 16:36:24

这是我从客户端的模块基类中的属性访问propertyvalue的方式.

Here is how I am accessing a propertyvalue from a property in a module base class I have for a client.

public string SomeKey
{
    get
    {
        var ppd = UserInfo.Profile.GetProperty("SomeKey");
        if (ppd.PropertyValue == string.Empty)
        {

            var SomeKeyValue = "blah"
            //update the user's profile property
            UserInfo.Profile.SetProfileProperty("SomeKey", SomeKeyValue);
            //save the user
            DotNetNuke.Entities.Users.UserController.UpdateUser(PortalId, UserInfo);
            //retrieve again
            return SomeKey;
        }
        string returnValue = ppd.PropertyValue ??
                             (String.IsNullOrEmpty(ppd.DefaultValue) ? String.Empty : ppd.DefaultValue);
        return returnValue;
    }
}