protected voidPage_Load (Objectsender, 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; stringLoginName =web. CurrentUser.LoginName.ToString (); Microsoft.SharePoint.SPUser u=web. Siteusers[loginname]; Microsoft.SharePoint.SPListItem it=list. Items.getitembyid (u.id); stringsql ="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) { stringdisplayName = dt. rows[0]["DisplayName"]. ToString (); Label1.Text="welcome you,"+ displayname+"! "; if(DisplayName! = it["Title"]. ToString ()) {it["Title"] = dt. rows[0]["DisplayName"]. ToString (); It. Update (); Page.Response.Redirect (Page.Request.Url.ToString ()); } } } }
Modify the SharePoint platform login display name