1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / cc2:ButtonSelector in ImageEditorDialog.aspx for loading images

cc2:ButtonSelector in ImageEditorDialog.aspx for loading images

4 posts, 1 answered
  1. Darren
    Darren avatar
    72 posts
    Registered:
    19 Mar 2008
    22 Jul 2009
    Link to this post
    I've created a site with Sitefinity and everything is working perfectly except I need to create a profile page to allow people who've registered with the site to manage their personal profile.

    So I've created a profile page containing a ManageProfile control which is my own templated version of the built in control.
    Since I'm effectively trying to create a page similar to the 'My Profile' page in the CMS I've actually copied this page into the EditTemplate block along with the code behind and confirmed that this is working fine.

    The one issue I have is the Profile Photo.
    This is using the cc2:ButtonSelector control linked to ImageEditorDialog.aspx.
    The problem is when you open the photo upload control you also have the option to choose a photo from a photo library. I don't want these users to have access to the CMS so when they click the link to open the photo libraries you get an error page since the page being requested isn't accessible.
    This control appears to be precompiled so is there a property or way to disable the option to load from a library? I was thinking of adding some code to check the current users role and if it isn't an admin the link is hidden and disabled else the link is left as is.

    Since the image upload control works so well I was hoping to just use the built in control that ships with Sitefinity otherwise I'll be using FileUpload controls in the user control templates which won't be as functional.
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    22 Jul 2009
    Link to this post
    Hello Darren,

    Thank you for using our services.

    I have prepared for you some control templates that you should add to your project in order to achieve the desired functionality. First of download the archive I have attached. I will now guide you step by step how to achieve what you want:

    1)  In the MyCustomControls/ControlTemplates/ directory of the archive I have attached you will find the necessary control templates, plus some resource files for localization. Copy/paste them to a directory in your project (together with their code files). I will use the MyCustomControls/ControlTemplates as an example throughout the next few steps.

    2) Upon the template of your custom profile control. Go to the cc2:ButtonSelector tag and modify it as follows (to point to the directory, where your control templates are):

    <cc2:ButtonSelector ID="ButtonSelector1"  
       WindowNavigateUrl="~/MyCustomControls/ControlTemplates/ImageEditorDialog.aspx"  
       AssociatedControls="Photo_Hidden,Photo"  
       ItemTemplatePath="~/MyCustomControls/ControlTemplates/ButtonSelector.ascx"  
       runat="server" cssclass="changePhotoSelector"  
       ButtonText="<%$Resources:ChangePhoto%>" /> 

    3) Open the ImageEditorDialog.aspx dialog and modify the following tag as followis (to point to the directory, where your control templates are):

    <lib:ImageEditorDialog runat="server" DisplayMode="Images"  
       ControlTemplatePath="~/MyCustomControls/ControlTemplates/ImageEditorDialog.ascx"/> 

    4) Copy the RadWindow.skin file to the theme that your website is using. If for example you are using the White fluid theme copy the skin file to ~/App_Themes/White fluid/. This file tells the RadWindow that holds the dialog what skin to use, i.e. it defines its look and feel. It is now set to use the default skin, but you can change it as you wish. If you are going to use custom skin make sure to set EnableEmbeddedSkins="false" property. For more information on the embedded skins of the RadWindow take a look here.

    I have alos attached captures to demonstrate the behavior of the control when logged in as administrator, or as user. Please, note that you will need to set up permissions for regular users to upload to a specific library, that will hold profile images. If you do not do this images will be uploadded to ~/Images folder in your project, please make sure that this folder exists.

    This should do the trick. If you have any questions regarding Sitefinity, please feel free to contact us.

    Regards,
    Rado
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
    Answered
  3. Darren
    Darren avatar
    72 posts
    Registered:
    19 Mar 2008
    24 Jul 2009
    Link to this post
    Perfect, thank you very much, worked a treat.
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    24 Jul 2009
    Link to this post
    Hello Darren,

    Thank you for the feedback.

    Always glad to help the community. If you have more questions, please feel free to reach us through the forums or raise a ticket if you experience difficulties developing with Sitefinity.

    Regards,
    Rado
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Register for webinar
4 posts, 1 answered