I've got Sitefinity 7.0 and created a custom field through the new interface. In this case, it's an image field called PageBannerImage. I've selected an image for a specific page and am now trying to pull and use this value from the code-behind of my master page.
To get the current page I'm calling:
The Attributes collection under currentPage has the keys "RequireSsl" and "IncludeScriptManager", but not my custom attribute.
but this returns null.
I've also tried getting the page via the fluent interface, but the Attributes for that are null.
Thank you! I spent way too much time trying to figure this out. The documentation has examples on how to create and edit the field, but I couldn't find anything when it came to retrieving the value.
For anyone else who is doing this, GetValue returns an object, which I cast to Telerik.Sitefinity.Libraries.Model.Image and used the MediaUrl property to get the url of the image.
I have a method where I obtain a list of pages:
public IQueryable<PageData> RetrieveCollectionOfPrograms()
PageManager pageManager = PageManager.GetManager();
IQueryable<PageData> pages = pageManager.GetPageDataList();
I call that elsewhere, so that I may then print out a table containing one or more of the custom fields that I have for those pages. It sorta looks like this:
var table = new List<CourseCatalogTableModel>();
var pageCollection = RetrieveCollectionOfPrograms().AsEnumerable().OrderBy(x => Guid.NewGuid()).Take(1000);
foreach(PageData page in pageCollection)
degreeProgram = collection.GetValue("Title"),
areaStudy = collection.GetValue("areaOfStudy");
The line where I am trying to access "areaOfStudy" does not work and I get an error saying "wrong custom field". Any idea how to access that?