標籤:
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { SPSite siteCollection = null; SPWeb web = null; siteCollection = SPContext.Current.Site; web = siteCollection.RootWeb; web.AllowUnsafeUpdates = true; Microsoft.SharePoint.SPList list = web.SiteUserInfoList; string loginName = web.CurrentUser.LoginName.ToString(); Microsoft.SharePoint.SPUser u = web.SiteUsers[loginName]; Microsoft.SharePoint.SPListItem it = list.Items.GetItemById(u.ID); string sql = "select ISNULL(DisplayName,‘‘) as DisplayName from aspnet_UsersInfo where UserName=‘" + UserInfo.SplitStr(loginName) + "‘"; DataTable dt = CommonExecSql.RetDs(sql, ConnectionEnum.StrConDataBaseUserManage).Tables[0]; if (dt.Rows.Count != 0) { string displayName = dt.Rows[0]["DisplayName"].ToString(); Label1.Text = "歡迎您," + displayName+"!"; if (displayName != it["Title"].ToString()) { it["Title"] = dt.Rows[0]["DisplayName"].ToString(); it.Update(); Page.Response.Redirect(Page.Request.Url.ToString()); } } } }
修改SharePoint平台登入者顯示名稱