SharePoint: Use C# or CAML to read contact person (etc) for current page.

I created custom web-part.  How can I read  (C# or CAML) contact person (i.e) for current page? This information would allow me to customize web part / send email and so on.
Who is Participating?
ivan_vaguninConnect With a Mentor Commented:
Hi! Then I guess you want to get PublishingContact field of the current publishing page. Try this:

SPFile file = SPContext.Current.Web.GetFile(HttpContext.Current.Request.A
string pageFile = pubWeb.GetFile(.Current.Request.Url.ToString());
SPListItem pageItem = pageFile.Item;
SPField field = pageItem.Fields.GetFieldByInternalName("PublishingContact");
object objValue = pageItem[field.Id];
SPFieldUserValue contactValue = objValue != null ? new SPFieldUserValue(SPContext.Current.Web, objValue.ToString()) : null;
Hi! Do you mean information from contact webpart?
tolppaAuthor Commented:
My problem is very simple one. Basically I need to query information from current page / site. Lets say I have custom content type X with fields a, a, c. How do I query column a? How do I query Contact Person(?) field user is needed to to fill when new site is created.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.