【问题标题】:How to update dotnetnuke userprofile image in codebehind?如何在后面的代码中更新 dotnetnuke 用户配置文件图像?
【发布时间】:2011-10-14 12:33:53
【问题描述】:

我正在构建我自己的"user profile" 模块,其中一个选项,用户可以更改他的默认dnn 个人资料图像。我在“在后面的代码中”执行此操作时遇到问题。我正在使用c#

这是我目前所拥有的:

UserInfo myDnnUser = this.UserInfo;
myDnnUser.Profile.InitialiseProfile(PortalId);

myDnnUser.Profile.SetProfileProperty("Photo", "new filename");
myDnnUser.Profile.SetProfileProperty("PhotoURL", "new url");

ProfileController.UpdateUserProfile(myDnnUser);

但它不起作用,当我查看 dnn 使用的“文件”表时,它仍然是相同的(旧)文件名。

有什么想法吗?

【问题讨论】:

    标签: asp.net dotnetnuke dotnetnuke-module


    【解决方案1】:

    涉及三个表:UserProfileProfilePropertyDefinitionFiles

    UserProfile 存储 ProfilePropertyDefinitions 的 PropertyValues。

    “照片”PropertyName 的预期 PropertyValue 是对 Files 表的 FileID 引用,而不是文件名。设置Photo之前,需要先获取FileID:

        var objFiles = new FileController();
        FileInfo objFile = objFiles.GetFile("filepath", PortalID);
        myDnnUser.Profile.Photo = objFile.FileId;
        ProfileController.UpdateUserProfile(myDnnUser);
    

    PhotoURL 是一个只读属性,用于检索 UserProfile 的 Photo 属性的 url。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-27
      • 2020-04-15
      • 2017-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多