I want to get the details about a field on umbraco contentpage where property type is textbox and alias or id is not known
0
votes
1 Answers
1
votes
If you want to get the property without knowing the alias or id, then you will need to iterate though the properties and you may get more than one of that type. I'm not sure what the context is for this, but it appears that the Umbraco published cache does not include the property editor type. This means you can't do something like the following in a view:
foreach (var property in Model.Properties.Where(x => x.PropertyType.PropertyEditorAlias == "Umbraco.Textbox"))
{
var propValue = property.Value;
}
But you can use the ContentService to get this data:
var docProperties = ApplicationContext.Services.ContentService.GetById(Model.Id).Properties.Where(x => x.PropertyType.PropertyEditorAlias == "Umbraco.Textbox");
foreach (var property in docProperties)
{
var propValue = property.Value;
}
Warning, this will query the database as it is not using the Umbraco Cache.