I get the error message "Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions."
I tried adding .First() so that I would only get a single property, not a list, but it's still giving the same error. I'm kind of a noob, so trying to understand that SO article.
How could I allow a member to edit his picture, which is an image cropper?
I'm working off the top of my head here but I'd probably assign it to a variable first, so something like:
@{ // Rememeber - an exception will be thrown here if there are no items in the // model where Name == "picture" var item = profileModel.MemberProperties.First(p => p.Name=="picture"); }
<!-- some markup --> @Html.EditorFor(m => item, "Umbraco.ImageCropper")
Ok, I hacked together a little piece of code that makes it compile:
if (profileModel.MemberProperties[i].Alias == "picture")
{
@Html.EditorFor(m => profileModel.MemberProperties[i].Value, "Umbraco.ImageCropper");
}
But this just gives me the JSON string for the imagecropper.
These comments are in the profile editor snippet:
@*
By default this will render a textbox but if you want to change the editor template for this property you can
easily change it. For example, if you wanted to render a custom editor for this field called "MyEditor" you would
create a file at ~/Views/Shared/EditorTemplates/MyEditor.cshtml", then you will change the next line of code to
render your specific editor template like:
@Html.EditorFor(m => profileModel.MemberProperties[i].Value, "MyEditor")
*@
I can't really help without seeing more of the code / context etc, but I don't think you need to be using an editor template (this is a sort of partial view), it sounds more like you want to insert the Umbraco Image Cropper itself.
I'm not familiar with this, so unfortunately can't help :(
Image cropper on member profile editor
I want members to be able to edit their pictures, which is a square image cropper.
I used the profile editor snippet and tried the following, but it does not work:
I get the error message "Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions."
Please help?
Hi,
This is a .NET error, not an Umbraco issue. It's because you are calling an extension method on MemberProperties.
http://stackoverflow.com/questions/9925728/templates-can-be-used-only-with-field-access-property-access-single-dimension
Oh, I see. Thanks Hywel, I didn't realise that.
I tried adding .First() so that I would only get a single property, not a list, but it's still giving the same error. I'm kind of a noob, so trying to understand that SO article.
How could I allow a member to edit his picture, which is an image cropper?
Oh, I get it now. A member. MemberProperties is a method.
So will I have to make a new strongly typed model?
I'm working off the top of my head here but I'd probably assign it to a variable first, so something like:
Ok, I hacked together a little piece of code that makes it compile:
But this just gives me the JSON string for the imagecropper.
These comments are in the profile editor snippet:
So what do?
Maybe the problem is that I assumed I could use the Cropper editor as an editor template.
Hey,
I can't really help without seeing more of the code / context etc, but I don't think you need to be using an editor template (this is a sort of partial view), it sounds more like you want to insert the Umbraco Image Cropper itself.
I'm not familiar with this, so unfortunately can't help :(
Did anyone ever figure this out?
Is it possible to create an editor template that inherits the Image Cropper?
+1 to this query I am currently trying to do this as well.
is working on a reply...