I am developing a visual web part that will do some some heavy operations. It is a visual web part in SharePoint 2013, on premise.
I want to load my data asynch. Ajax toolkit is not compatible and gives problem, as far as I have heard and tried.
Any tips for how my web part can load asynch on this sample code?
This is my code in c#
protected void Page_Load(object sender, EventArgs e)
{
GetCurrentUserData();
}
private void GetCurrentUserData()
{
try
{
var web = SPContext.Current.Web;
var currentUser = web.CurrentUser.LoginName;
var serverContext = SPServiceContext.GetContext(web.Site);
var profileManager = new UserProfileManager(serverContext);
var currentUserprofile = profileManager.GetUserProfile(currentUser);
var displayName = currentUserprofile.DisplayName;
LblName.Text = displayName;
web.Dispose();
}
catch (Exception ex)
{
LblError.Text = "Exception.";
}
}
This is my code in asp.net
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WpProfilePropertiesUserControl.ascx.cs" Inherits="XX.MySite.SPI.WebParts.WpProfileProperties.WpProfilePropertiesUserControl" %>
<div>
<asp:Label ID="LblError" runat="server" Text=""></asp:Label>
<asp:Label ID="LblName" runat="server"></asp:Label>
</div>