Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I am retriving umbraco field like this:
Umbraco.Field(string fildalias)
How to check if field exist/is created ?
if (Umbraco.Field("itemsPerSite") != null) is not enough
Thansk
Hi Anders,
You can do it like this:
if (CurrentPage.HasValue("itemsPerSite")){ @Umbraco.Field("itemsPerSite")}
The HasValue check if the field has a value of the current page that you are viewing in the browser.
Hope this helps,
/Dennis
if(CurrentPage.HasProperty("itemsPerSite")) { }
Thanks. for anwsers. Sorry forgot to say i am not able in usinge currentpage or model.
Is there another solution?
The @Umbraco.Field(string field) returns the value of that field from the Current Page. http://our.umbraco.org/documentation/Reference/Querying/UmbracoHelper/#Field%28stringfield%29 If you want to access a property on the parent or so, then you should have a look at the axis: http://our.umbraco.org/documentation/reference/templating/macros/razor/using-razor-axes
Or have a look on this cheat sheets, there a both dynamic razor and strongly typed razor, I know it says for V6, but you should be good with it in version 7 also. http://our.umbraco.org/projects/developer-tools/umbraco-v6-mvc-razor-cheatsheets
If you can tell more a about where the user should type in the value, of the field and your content structure, maybe we can help you closer to solve your issue.
Try this one, Remember to inherit the template from UmbracoTemplatePage
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ if (Model.Content.HasProperty("itemsPerSite")) { } }
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Check if Umbraco.Field exist
I am retriving umbraco field like this:
Umbraco.Field(string fildalias)
How to check if field exist/is created ?
if (Umbraco.Field("itemsPerSite") != null) is not enough
Thansk
Hi Anders,
You can do it like this:
The HasValue check if the field has a value of the current page that you are viewing in the browser.
Hope this helps,
/Dennis
Thanks. for anwsers. Sorry forgot to say i am not able in usinge currentpage or model.
Is there another solution?
Hi Anders,
The @Umbraco.Field(string field) returns the value of that field from the Current Page. http://our.umbraco.org/documentation/Reference/Querying/UmbracoHelper/#Field%28stringfield%29 If you want to access a property on the parent or so, then you should have a look at the axis: http://our.umbraco.org/documentation/reference/templating/macros/razor/using-razor-axes
Or have a look on this cheat sheets, there a both dynamic razor and strongly typed razor, I know it says for V6, but you should be good with it in version 7 also. http://our.umbraco.org/projects/developer-tools/umbraco-v6-mvc-razor-cheatsheets
If you can tell more a about where the user should type in the value, of the field and your content structure, maybe we can help you closer to solve your issue.
Hope this helps,
/Dennis
Try this one, Remember to inherit the template from UmbracoTemplatePage
is working on a reply...