Hi everyone, i'm trying to manually update the user profile picture in a custom module (HvProfile in this case).
So far, I put the DNNFilePicker control in my view.ascx, as follows:
<dnn:DnnFilePicker id="filepicker1" runat="server"></dnn:DnnFilePicker>
It is working right. Uploads a pic and inserts a new line at "files" SQL table, gives it a route path, a fileID and so on.
To save the "Photo" profile property it's easy from .cs codebehind:
UserInfo myDnnUser = this.UserInfo;
myDnnUser.Profile.SetProfileProperty("Photo", filepicker1.fileID());
However, if i put this code in my view.ascx.cs it loads it sequentially on page load, so it doesn't wait for the user to upload the pic and gets a wrong filepicker1.fileID.
So, to get filepicker1.fileID, i must wait the user to upload the file, i can only call that code after the image is uploaded by the DnnFilePicker control (filepicker1 in my case")
To achieve this, i thought i could run that code calling a webservice, and i created a javascript onclick event which calls that web service when i'm sure the image is uploaded with the control.
Now i have the problem that i can't get the filepicker1.fileID as filepicker1 seems not to be declared in the webservice.
I tried getting it by:
using System.Net.Http;
using System.Web.Http;
using DotNetNuke.Web.Api;
using DotNetNuke.Entities.Users;
using DotNetNuke.Services.FileSystem;
using DotNetNuke.Web.UI.WebControls;
using DotNetNuke.UI.UserControls;
namespace Christoc.Modules.HvProfile.clases
{
public class PostUserProfileController : DnnApiController
{
[AllowAnonymous]
[HttpPost]
public HttpResponseMessage changeUserInfo()
{
var fp = Christoc.Modules.HvProfile.View.filepicker1;
UserInfo myDnnUser = UserController.Instance.GetCurrentUserInfo();
myDnnUser.Profile.SetProfileProperty("Photo", fp.FileID.ToString());
return null;
}
}
}
However var fp returns null and i'm stuck, seems like filepicker1 class, object or whatever it is, is not shared between the view and the webservice, or i might call it wrong.
filepicker1 is defined like this in my view.ascx.designer.cs:
public static global::DotNetNuke.Web.UI.WebControls.DnnFilePicker filepicker1;
Any help is welcome, bye and thanks.