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

Forums / Developing with Sitefinity / Using SF Image Library to select an image

Using SF Image Library to select an image

3 posts, 1 answered
  1. IH
    IH avatar
    11 posts
    Registered:
    13 Jan 2010
    13 Jan 2010
    Link to this post
    Hello,

    I am trying to select an Image from the SF Image Library.

    At this time I am able successfully select an image from ImageManager, i.e. code:
            Dim imageManagerParameters As New FileManagerDialogParameters() 
            imageManagerParameters.ViewPaths = New String() {"/Images"
            imageManagerParameters.UploadPaths = New String() {"/Images"
            imageManagerParameters.DeletePaths = New String() {"/Images"
            imageManagerParameters.MaxUploadFileSize = 5000000 
           
            Dim imageManager As New DialogDefinition(GetType(ImageManagerDialog), imageManagerParameters) 
            imageManager.ClientCallbackFunction = "ImageManagerFunction" 
            imageManager.Width = Unit.Pixel(694) 
            imageManager.Height = Unit.Pixel(440) 
            
            DialogOpener1.DialogDefinitions.Add("ImageManager", imageManager) 

    and
     <button onclick="$find('<%= DialogOpener1.ClientID %>').open('ImageManager', {CssClasses: []});return false;"
                                            Open ImageManager</button> 

    and
        <script type="text/javascript"
                                            function ImageManagerFunction(sender, args) { 
                                                var selectedItem = args.get_value(); 
                                                //                                            debugger; 
     
                                                var txt = $get('<%= txt.ClientID %>'); 
                                                if ($telerik.isIE) { 
                                                    txt.value = selectedItem.src; 
                                                } 
                                                else { 
                                                    var path = args.value.getAttribute("src", 2); 
                                                    txt.value = path
                                                } 
                                            } 
     
                                             
                                        </script> 

    ...

    Now what I want is that when I click the button, I want to see the dialog with images present in SF Image Library.

    Thanks
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    13 Jan 2010
    Link to this post
    Hello IH,

    You can use the already existing functionality. Add a ButtonSelector control in image mode:
    <%@ Register TagPrefix="sfLib" Namespace="Telerik.Libraries.WebControls" Assembly="Telerik.Libraries" %>
    ...
    <asp:TextBox ID="ImageURL" CssClass="EditURL" Columns="40" runat="server" />
    <sfLib:ButtonSelector
        ID="btnSelectPage" WindowNavigateUrl="~/Sitefinity/UserControls/Dialogs/ImageDialog.aspx"
        AssociatedControls="ImageURL" runat="server" ItemTemplatePath="~/Sitefinity/Admin/ControlTemplates/Libraries/Dialogs/ButtonSelector.ascx" />

    This should do the trick.

    Greetings,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Answered
  3. IH
    IH avatar
    11 posts
    Registered:
    13 Jan 2010
    14 Jan 2010
    Link to this post
    That worked like a star!

    Thanks
Register for webinar
3 posts, 1 answered