Try our conversational search powered by Generative AI!

Image picker on page

Vote:
 

I would like to put an image picker on a page to let a user pick an image from episerver filesystem, like the "Url to Image" property inside episerver.

How do I go about this?

#49624
Mar 25, 2011 10:09
Vote:
 

Hi!

You could use a Property with a backing property of type PropertyFileUrl and set EditMode="true". This would require that you opened up access to some aspx files if the user does not have access to the UI-folder. If this is not possible you need to create your own UI for your image selection and work against the UnifiedFile-API.

/Linus

#49635
Mar 25, 2011 13:13
Vote:
 

Im a bit confused on how the code would look like in the first case.
The picker will be used on an extranet page and the user will have access to the ui-folder.

#49636
Mar 25, 2011 13:39
Vote:
 

Ok, its friday. Had forgotten to set EditMode="true" so now I can pick from the site.

Another question that pops up is how do I get the value of the property in codebehind?

#49638
Mar 25, 2011 13:56
Vote:
 

If the property resides on the page, just set CurrentPage = CurrentPage.CreateWritableClone() in page init when in edit mode. Then you need to call PrepareForSave in your save handler before actually saving the page.

#49639
Mar 25, 2011 14:37
Vote:
 

Thanks for the tip but in this case we want to save the selected value to a database and need to extract the value of the "picker".

#49641
Mar 25, 2011 14:42
Vote:
 

Set the InnerProperty to a writable version of a PropertyUrlControl early in the page cycle. Then you can extract the data from the Value property on your PropertyUrlControl.

#49645
Mar 25, 2011 14:56
Vote:
 

Something like this:

var propertyUrl = new PropertyUrl {Value = ImageLink.Url};
var propertyUrlControl = new Property(propertyUrl) {EditMode = true, ID = "Url"};

// Then on postback

((IPropertyControl)propertyUrlControl.Controls[0]).ApplyChanges();

var value = propertyUrlControl.PropertyValue as string;

    

 

 

#49685
Mar 28, 2011 22:26
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.