Editor in grid image manager paths

4 posts, 0 answers
  1. Sauge
    Sauge avatar
    24 posts
    Member since:
    Feb 2013

    Posted 09 Dec 2013 Link to this post

    Hi there

    I am trying to set the image manager paths, in an editor, in a template column of a radgrid from code behind like this:

    Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs)
            If TypeOf e.Item Is GridEditableItem And e.Item.IsInEditMode Then
                Dim editor1 As RadEditor = e.Item.FindControl("Radeditor1")
                Dim UserId As String

                UserId = Membership.GetUser().ProviderUserKey.ToString()

                editor1.ImageManager.ViewPaths = New String() {"~/images/users/" + UserId + "/uploads"}
                editor1.ImageManager.DeletePaths = New String() {"~/images/users/" + UserId + "/uploads"}
                editor1.ImageManager.UploadPaths = New String() {"~/images/users/" + UserId + "/uploads"}
                editor1.ImageManager.EnableAsyncUpload = True
                editor1.ImageManager.SearchPatterns = New String() {"*.jpeg", "*.jpg", "*.bmp", "*.gif", "*.png"}
            End If

        End Sub


    Please could someone tell me what am I doing wrong here
  2. Vessy
    Admin
    Vessy avatar
    2213 posts

    Posted 12 Dec 2013 Link to this post

    Hi Sauge,

    The latest moment of the page life cycle in which you can configure ImageManager's paths is the Page_Load event. Doing it in a later event it may bring many unexpected errors, causing the control not to function properly.

    Could you move the configuration from the provided code snippet to the Page_Load event and see whether the problem still occurs?

    Regards,
    Veselina Raykova
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. Sauge
    Sauge avatar
    24 posts
    Member since:
    Feb 2013

    Posted 13 Dec 2013 Link to this post

    Hi Veselina

    Thank you for your response, but I am having trouble referencing the image manager from page load as the image manager is in an editor contained in a template column of a radgrid

    Have you any idea how I can do this

    Thank you in advance :-)
  4. Angel Petrov
    Admin
    Angel Petrov avatar
    1140 posts

    Posted 17 Dec 2013 Link to this post

    Hi Sauge,

    You can access the image manager by obtaining a reference to the cell of the edit item and then using FindControl to locate the control.
    editableItem["ColumnUniqueName"].FindControl("ImageManager")
    More information on accessing cells and rows is available in this help article.

    Additionally note that the PageLoad event is fired too early and the edit item may not be created. That said it would be best to show us the markup and relevant code-behind so we could provide a more precise answer.

    Regards,
    Angel Petrov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top