Surface Controllers has no knowledge of what back office page you are on or editing (I think). If you wanted to retrieve properties for a back office page being edited, you would have to pass the current page ID via your Surface Controller request.
public class MySurfaceController : SurfaceController
{
public object MyMethod(int id)
{
var page = Umbraco.TypedContent(id);
var propertyValue = page.GetPropertyValue("alias");
}
}
Also, if you are using a controller for a custom back office property editor, you might want to look at using UmbracoAuthorizedApiController instead of SurfaceController.
"Umbraco.Core.Models.IPublishedContent" does not contain a definition for GetPropertyValue and no extension method 'GetPropertyValue' accepting the argument of type Umbraco.Core.Models.IPublishedContent could be found.
To fetch properties from umbraco backoffice to controller
Hi all,
How can I fetch selected properties from backoffice into surface controller?
Thanks,
Manasa
Hi Manasa,
What do you mean by selected properties?
Surface Controllers has no knowledge of what back office page you are on or editing (I think). If you wanted to retrieve properties for a back office page being edited, you would have to pass the current page ID via your Surface Controller request.
Also, if you are using a controller for a custom back office property editor, you might want to look at using UmbracoAuthorizedApiController instead of SurfaceController.
I hope that helps.
Thanks, Dan.
I tried with your code.
I get the below error:
"Umbraco.Core.Models.IPublishedContent" does not contain a definition for GetPropertyValue and no extension method 'GetPropertyValue' accepting the argument of type Umbraco.Core.Models.IPublishedContent could be found.
Thanks,
Manasa
Hmmm strange. Do you have a sample of the code you are trying to get working please? It might help find the issue.
I'm not sure why GetPropertyValue isn't working. You could always try:
Thanks, Dan.
Thanks Dan.
We used page.GetProperty("alias name").Value.ToString().
Fixed the issue.
is working on a reply...