MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

Separate File Galleries?  (Mono Support )

Viewed 57494 time(s), 21 post(s) 4/16/2012 1:11:08 PMby erin0201

Related topics

erin0201

erin0201

4/23/2012 4:52:56 PM
Could this require that the pages be recompiled to get it to look at the codebehind file?
Could you see if this is true? If not, could you please let me know what it looks like I'm doing wrong with trying to set the InitialPath in the codebehind file?
I have also tried setting the initialpath this way:

ctlFileExplorer.InitialPath = Page.ResolveUrl("/Intranet");

It doesn't seem to matter what I set it to. The page doesn't act like it's looking at the codebehind file at all.
If it helps, in Visual Web Developer 2010 Express I'm getting an error in the aspx.cs file that says "The name 'ctlFileExplorer' does not exist in the current context. I've tried to make sure that the namespace and the partial class are correct between the aspx and aspx.cs file, but maybe I'm missing something?

Thanks!!
Erin
This content has not been rated yet. 
453 Reputation 61 Total posts
denis

denis

4/23/2012 4:56:52 PM
Hi Erin,
You cannot just put the code behind file there, as the MonoX solution code is precompiled. In your scenario, FileAdmin actually has a property named RootPath that allows you to change the root folder (by default it is set to "/").
The best way to achieve what you want would be to create your own page that inherits from the MonoSoftware.MonoX.Admin.FileAdmin class and set the property in the OnInit event handler.
This content has not been rated yet. 
7207 Reputation 956 Total posts
erin0201

erin0201

4/23/2012 7:00:59 PM
Ok, I created my own FileAdminIT aspx and aspx.cs file.
Were you meaning that I could set the RootPath in the code behind for that file?  I can do this even without having the source code recompiled?

  EDIT:  I got it to work with a script at the top of the aspx file!  Now I can create a couple more of these files for the different user groups/roles.

Thanks so much for your help!!

Here is what worked for me for anyone that wants to use the FileAdmin page/control for their own FileManagement instead of the basic FileGallery and FileView controls:
ASPX Page Code:
<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="/MonoX/MasterPages/Default.Master" CodeBehind="FileAdminIT.aspx.cs" EnableTheming="true" Theme="Default" Inherits="MonoSoftware.MonoX.Admin.FileAdmin" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="MonoXControls" Namespace="MonoSoftware.MonoX.Controls" Assembly="MonoX" %>
<%@ MasterType TypeName="MonoSoftware.MonoX.BaseMasterPage" %>   
 
<asp:Content ID="Content1" ContentPlaceHolderID="cp" Runat="Server">
    <script runat="server" language="C#">
        protected override void OnInit(EventArgs e)
        {
        base.OnInit(e);
          //Change the rootpath to the starting folder for your File Administration needs.
        RootPath = "/Intranet";
        }
        </script>
     <telerik:RadCodeBlock ID="cb1" runat="server">
        <script language="javascript">
        var selectedTemplateFile = "";
 
        function GridMenuItemClicked(sender, args)
        {
            var oExplorer = $find("<%= ctlFileExplorer.ClientID %>");
            var itemValue = args.get_item().get_value();
            var itemText = args.get_item().get_text();
            if (itemValue != null) {
                if (itemValue.indexOf("newpage|") >= 0) {
                    selectedTemplateFile = itemValue.replace(/newpage\|/g, "");
                    radprompt(ResourceManager.GetString("NewPagePrompt"), NewPageCallback, 330, 100, "", ResourceManager.GetString("New"), " ");
                    return false;
                }
                if (itemValue == "PageProperties")
                {
                    var itemPath = oExplorer.get_selectedItem().get_path();
                    //.aspx extension interferes with URL rewriting so it is replaced to _aspx_ and decoded at the server side
                    var oWindow = window.radopen("FileManagerPropertiesDialog.aspx?pageUrl=" + encodeURIComponent(itemPath).replace(/\.aspx/gi, "_aspx_"), "PageProperties");
                    oWindow.setSize(700, 650);
                    oWindow.set_modal(true);
                    oWindow.center();
                    oWindow.OnClientPageLoad = function() {
                        oWindow.SetTitle(itemText);
                    }
                     
                }
            }
        }
         
        function NewPageCallback(arg)
        {
            if (arg)
            {
                window.top.setTimeout(function() {
                    var ajaxManager = $find("<%= ajaxManager.ClientID %>");
                    ajaxManager.ajaxRequest("NewPage|" + arg + "|" + selectedTemplateFile);
                }, 0);
                return true;
                 
            }
        }
 
        function OnResponseEnd(sender, arguments) {
            var oExplorer = $find("<%= ctlFileExplorer.ClientID %>");
            oExplorer.refresh();
 
        }
 
        function OnFileOpen(sender, args) {
            var manager = sender.get_windowManager();
            var item = args.get_item();
            window.setTimeout(
            function() {
                var activeWindow = manager.getActiveWindow();
                if (!activeWindow)
                    return;
                activeWindow.set_behaviors(Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Maximize);
                if (item != null && item.get_path().substr(0, 2) == '//')
                    activeWindow.setUrl(item.get_path().substr(1, item.get_path().length));
                activeWindow.setSize(700, 700);
                activeWindow.center();
            }, 20);
        }
         
 
        </script>
    </telerik:RadCodeBlock>
    <MonoXControls:MonoXWindowManager ID="windowDialog" runat="server" Modal="true"></MonoXControls:MonoXWindowManager>
    <div style="width:100%;height:100%;margin-left:auto;margin-right:auto;" class="fileExplorerContainer">
    <center>
    <telerik:RadFileExplorer OnClientFileOpen="OnFileOpen" runat="server" ID="ctlFileExplorer" Width="99%" Height="600px" CssClass="fileExplorer" DisplayUpFolderItem="true" ExplorerMode="Default">
  <Configuration SearchPatterns="*.*" DeletePaths="/Intranet" UploadPaths="/Intranet/" ViewPaths="/Intranet/">
        </Configuration>
    </telerik:RadFileExplorer>
    </center>
    </div>
    <telerik:RadAjaxManager runat="server" ID="ajaxManager" OnAjaxRequest="ajaxManager_AjaxRequest" ClientEvents-OnResponseEnd="OnResponseEnd">
       <AjaxSettings>
       <telerik:AjaxSetting AjaxControlID="ajaxManager">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="ctlFileExplorer.Grid" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
</asp:Content>

</code>
This content has not been rated yet. 
453 Reputation 61 Total posts
denis

denis

4/24/2012 4:05:50 PM
Glad to hear that you resolved it by putting a script directly into the page (control) - this is an alternative way of doing it that does not require recompilation. The codebehind approach would require that you compile your custom page or control and put the resulting DLL to the bin folder.
This content has not been rated yet. 
7207 Reputation 956 Total posts
erin0201

erin0201

4/26/2012 3:27:48 PM
Hi Denis!

I was wondering if the FileGallery or FileView parts also have a Rootpath or target path or similar variable that I can set on pageload so that they will only load files from a certain folder into view? The FileAdmin page works great for those that I want to be able to upload/load their own files to the directory, but now I would like to add a page that is visible to other users where they can only "see" the files in that directory and not edit/upload/delete them.

You had mentioned I would need code that would populate the gallery on page_load. Is this something that I could do by just setting a target path? Or is there more code that I need to have in the page_load control on the page with the FileGallery part?

Or is there an easy way to customize the FileAdmin class/control with variables that will hide the delete, upload, add new folder buttons along the top so that I could just make another FileAdmin page called like FileView that inherits the FileAdmin class that has the FileAdmin lacking those options?

Thanks!
Erin

EDIT: It turns out it is really easy to have the delete and upload functions removed by adding some RadFileExplorer functions!
This is from Telerik's site. http://www.telerik.com/support/kb/aspnet-ajax/fileexplorer/remove-delete-and-upload-commands.aspx

Just in case anyone else needs these functions I will leave this reply! Also, I'm not sure why, but Delete is still there in the "right-click" menus. However, if you click delete it doesn't delete the file or folders. It actually takes on the function of "rename". Also, I tried getting rid of Rename and New Folder the same way as the other commands were removed, but they still show up. Their function is kind of messed up. Delete still tries to rename things, Rename doesn't work, and New Folder creates folders with the name of the folder you have selected without giving you an option to give it a name. It's like half of the functionality is still there, but not quite.
This content has not been rated yet. 
453 Reputation 61 Total posts
erin0201

erin0201

4/26/2012 3:28:58 PM
Are there are variables in the FileAdmin class to control removing Delete, Rename, Upload, and New Folder that I can set in the page_load?

Thanks!
Erin
This content has not been rated yet. 
453 Reputation 61 Total posts
erin0201

erin0201

4/26/2012 3:42:33 PM
Ok nevermind! I found out that I needed to add NewFolder to the code.
You have to have it remove Delete, Upload, Rename, and NewFolder to disable all of the functionality and weirdness. Now all those functions are either greyed out, missing from the toolbar, or don't do anything.

This effectively gives the Windows Explorer type of file explorer "view' to a user that shouldn't have access to change files, but still needs to be able to open, view, and browse.

Thanks!
Erin
This content has not been rated yet. 
453 Reputation 61 Total posts
erin0201

erin0201

5/2/2012 6:36:10 PM
Hi Again!


I'm wondering if there are other variables the FileAdmin class is using for the Telerik RadFileExplorer?

I would like to remove the right-click menu functions of creating a new
page or to totally remove the ability to right click completely would be
best!


Thanks for any help,

Erin
This content has not been rated yet. 
453 Reputation 61 Total posts
denis

denis

5/7/2012 8:54:57 AM
Hi Erin,
You would have to inherit the existing FileAdmin and set the visibility of the context menu in the PreRender event to false. Looking at your modificitaions, it might be a good idea to start from scratch and use FileExplorer control to do whatever you want - it appears that you want to change all existing methods.
This content has not been rated yet. 
7207 Reputation 956 Total posts
erin0201

erin0201

5/7/2012 12:45:48 PM
Hi Denis!

I tried setting one of the menus to false, but it didn't work. I did, however, comment out the onclick event for the page properties a new pages so that they wouldn't do anything if clicked so at least that helped.

How would I inherit the FileExplorer control without inheriting the FileAdmin class? Or...
I had tried putting the page onload event the command to clear the context menu, but this didn't work:

ctlFileExplorer.GridContextMenu.Items.Clear();

Is there another way to set the gridcontextmenu view to false?

I did get this command to work on setting the treeview contextmenu to not show up:

ctlFileExplorer.TreeView.ContextMenus.RemoveAt(0);
This content has not been rated yet. 
453 Reputation 61 Total posts
1 2 3