Setting viewpath for imagemanager in RadEditor

Thread is closed for posting
6 posts, 1 answers
  1. Matt
    Matt avatar
    9 posts
    Member since:
    Dec 2010

    Posted 27 Dec 2010 Link to this post

    If possible, how can I set the viewpaths property for the imagemanager in the Radeditor dynamically? I need to set this based on something like a TempData variable. I tried ...

     RadEditor_HTMLSource.ImageManager.ViewPaths = (String[])TempData["mykey"];

    But it's not set.

    Thanks
    Matt
  2. Rumen
    Admin
    Rumen avatar
    12848 posts

    Posted 28 Dec 2010 Link to this post

    Hi Matt,

    Here is the C# syntax:

    string[] viewImages = new string[] { "~/Images" };
    string[] uploadImages = new string[] { "~/Images/New" };
    string[] deleteImages = new string[] { "~/Images/New/Articles", "~/Images/New/News" };

    if (!IsPostBack)
    {
       RadEditor1.ImageManager.ViewPaths = viewImages;
       RadEditor1.ImageManager.UploadPaths = uploadImages;
       RadEditor1.ImageManager.DeletePaths = deleteImages;
    }

    You should debug your code and see why the value is not applied properly. You should also make sure that such a folder exists and that it has a sufficient permissions.

    Best regards,
    Rumen
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Matt
    Matt avatar
    9 posts
    Member since:
    Dec 2010

    Posted 28 Dec 2010 Link to this post

    Thanks but still not working. I can see the value being set for viewpaths but when I open the image manager the files are still not visible. I've confirmed that it works when I set the viewpaths in the mark up. The permissions are set correctly (Network Service has full control). 

    If I keep the code that sets the viewpaths and then set the viewpaths attribute in the markup the value from the markup is used. So, it looks that anything I do in code is ignored.

    I'm in a partial view but I tried it in a normal MVC page with the same problem.

    <div>
    <%
     RadEditor_HTMLSource.Content = (ViewData.Model.Mailing != null) ? ViewData.Model.Mailing.HTMLSource : "";
             if (!IsPostBack)
             {
                             RadEditor_HTMLSource.ImageManager.ViewPaths = (String[])TempData["SchoolId"];
                             RadEditor_HTMLSource.ImageManager.UploadPaths = (String[])TempData["SchoolId"];
                             RadEditor_HTMLSource.ImageManager.DeletePaths = (String[])TempData["SchoolId"];
                         }
                   %>
                   <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server">
                   </telerik:RadStyleSheetManager>
                   <telerik:RadEditor ID="RadEditor_HTMLSource" ExternalDialogsPath="~/Content/Controls/EditorDialogs/" 
                       runat="server" ContentFilters="MakeUrlsAbsolute"  DialogHandlerUrl="~/Telerik.Web.UI.DialogHandler.axd"
                       ToolsFile="~/Content/MailingTools.xml" Skin="Black">
                       <FlashManager MaxUploadFileSize="5242880" ViewPaths="~/Public" UploadPaths="~/Public" />
                       <MediaManager MaxUploadFileSize="5242880" ViewPaths="~/Public" UploadPaths="~/Public" />
                       <DocumentManager MaxUploadFileSize="5242880" ViewPaths="~/Public" UploadPaths="~/Public" />
                       
                      </telerik:RadEditor>
     
               </div>
  5. Matt
    Matt avatar
    9 posts
    Member since:
    Dec 2010

    Posted 29 Dec 2010 Link to this post

    I've updated to the latest version of ASP.net ajax but still an issue. Any others ideas on what to try?

    I tried to use an example project - 173294_mvcwithradeditor.zip - provided by Telerik on another post. This also doesn't work.
  6. Answer
    Rumen
    Admin
    Rumen avatar
    12848 posts

    Posted 30 Dec 2010 Link to this post

    Hi Matt,

    The <% %> server tags are executed when the page is rendered on the page, but the FileBrowser dialogs of RadEditor expect to be configured before the Page_Load event. Here is how to set the paths:

    <script runat="server" type="text/C#">
        protected void Page_Load(object sender, EventArgs e)
        {
            RadEditor_HTMLSource.Content = "test";
            if (!IsPostBack)
            {
                RadEditor_HTMLSource.ImageManager.ViewPaths = new string[] { "~/" }; ;
                RadEditor_HTMLSource.ImageManager.UploadPaths = new string[] { "~/" };
                RadEditor_HTMLSource.ImageManager.DeletePaths = new string[] { "~/" };
            }
        }
    </script>
    <telerik:radstylesheetmanager id="RadStyleSheetManager1" runat="server">
    </telerik:radstylesheetmanager>
    <telerik:radeditor id="RadEditor_HTMLSource"
        runat="server" contentfilters="MakeUrlsAbsolute"
         skin="Black"
         DialogHandlerUrl="~/Telerik.Web.UI.DialogHandler.axd"
         >
    </telerik:radeditor>


    Kind regards,
    Rumen
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  7. Matt
    Matt avatar
    9 posts
    Member since:
    Dec 2010

    Posted 30 Dec 2010 Link to this post

    Thanks, that solved it.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017