I've got another similar problem this time when I am trying to get a property using CurrentPage.PropertyValue. I am using the DAMP media picker to have an image for each block on a page. See code below.
When I do this I get the char' does not contain a definition for 'Url' error again I'm beginning to think the problem may lay elsewhere thanks for your help so far though
Looping through properties
Hi
I'm new to umbraco and using umbraco 6.1.6, I am trying to create a partialview that will create a grid of boxes with content.
In my partialview I want to loop through and get the content from each of the properties on the current node.
e.g my content has properties title1, title2, title3and I would like to do something like the following
@{
for (int i = 0; i < mainCount; i++)
{
<h1>@Umbraco.Field("title @i")</h1>
)
but I don't seem to be able to join the property name with the i variable
I hope that makes some sense any help gratefully recieved
Bal
Hi Balram and welcome to Our!
Try this:
Jeavon
that's great I could have sworn I'd tried that but it has worked now
thanks
Great!
Hi Again
I've got another similar problem this time when I am trying to get a property using CurrentPage.PropertyValue. I am using the DAMP media picker to have an image for each block on a page. See code below.
@if (CurrentPage.HasProperty("blockimage"+i) && CurrentPage.HasValue("blockimage"+i))
{
foreach (dynamic itemPhoto in CurrentPage.blockimage1)
{
<img src="@CropUp.GetUrl(@itemPhoto.Url, new ImageSizeArguments { CropAlias = "gallery" })" alt="@itemPhoto.Alt" class="img-polaroid" />
}
}
This works but I need to replace the 1 in this line foreach (dynamic itemPhoto in CurrentPage.blockimage1) with the value of i
any help appreciated
I'm pretty sure you need this:
When I do the above I get a different error
'char' does not contain a definition for 'Url' so I'm not sure what is happening
the CurrentPage.blockimage1 works okay but CurrentPage."blockimage"+i does not
Bal
Are you using the DAMP value converter?
yes I am
Ok, give this a try then:
HI Jeavon
When I do this I get the char' does not contain a definition for 'Url' error again I'm beginning to think the problem may lay elsewhere thanks for your help so far though
Bal
Could you try it strongly typed:
Please use edited above
That's great thanks Jeavon
Bal
is working on a reply...