This is a migrated thread and some comments may be shown as answers.

Dynamically set path

6 Answers 353 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
dipan
Top achievements
Rank 1
dipan asked on 17 Feb 2011, 05:13 AM
Hi I am trying to change FileExplorer path dynamically but its not getting change. I have one dropdown box and based on selected item I am trying to change the File Explorer path Dynamically.  Please see my code below:

<div class="settings">
        <h1>Media Libraries</h1>
        <div>
            <fieldset style="width: 250px;">
                <legend>Choose a Site</legend>
                <telerik:RadComboBox ID="ddlSite" runat="server" Width="200px" Height="100px" AutoPostBack="true"
                    EmptyMessage="Select a Site" EnableVirtualScrolling="true" OnSelectedIndexChanged="ddlSite_SelectedIndexChanged">
                </telerik:RadComboBox>
            </fieldset>
        </div>
        <div>
        <fieldset style="width: 250px;">
                <legend>Selected Site</legend>
                <asp:Label ID="lblSiteName" runat="server" Text=""></asp:Label>
            </fieldset>
        </div>
    </div>
    <table cellspacing="4" cellpadding="0" border="0" style="padding-left:10px;" >
        <tr>
            <td style="vertical-align: top;">
                
                <telerik:RadFileExplorer runat="server" ID="FileExplorer1" Width="1000px" Height="500px"
                    OnClientItemSelected="OnClientItemSelected" >
                </telerik:RadFileExplorer>
            </td>
            <td valign="top">
                <fieldset style="width: 230px; height: 220px">
                    <legend>Preview</legend>
                    <img id="pvwImage" src="" runat="server" alt=""
                        style="display: none; max-width:230px; max-height:220px; margin: 10px;  vertical-align: middle;" />
                </fieldset>
            </td>
        </tr>
        </table>
 
.cs page:
 
        protected void Page_Load(object sender, EventArgs e)
        {
            InitializeContainer();
            //set properties according to configuration panel
            FileExplorer1.VisibleControls = GetVisibleControls();
            FileExplorer1.EnableOpenFile = true;
            FileExplorer1.DisplayUpFolderItem = true;
            FileExplorer1.AllowPaging = true;
            FileExplorer1.EnableCreateNewFolder = true;
            FileExplorer1.Upload.Enabled = true;
            //if (!enableUpload.Checked)
            //{
            //    FileExplorer1.Configuration.UploadPaths = new string[0];
            //}
            if (!IsPostBack)
            {
                BindSite();
                lblSiteName.Text = ddlSite.SelectedItem.Text;
                 
                
                ////Set initial folder to open. Note that the path is case sensitive!
                FileExplorer1.Configuration.ContentProviderTypeName = typeof(CustomColumnsContentProvider).AssemblyQualifiedName;
                //FileExplorer1.InitialPath = Page.ResolveUrl(String.Format("~/SiteData/{0}/UserFiles/allowed.png",this.SiteID));
                this.SiteID = Convert.ToInt32(ddlSite.SelectedValue);
                string PagePath = Page.ResolveUrl(String.Format("~/SiteData/{0}/UserFiles/allowed.png", this.SiteID));
                string RootPagePath = Page.ResolveUrl(String.Format("~/SiteData/{0}/UserFiles", this.SiteID));
                //Set initial folder to open. Note that the path is case sensitive!
                // FileExplorer1.InitialPath = PagePath;
                FileExplorer1.Configuration.ViewPaths = new string[] { RootPagePath };
                FileExplorer1.Configuration.UploadPaths = new string[] { RootPagePath };
                FileExplorer1.Configuration.DeletePaths = new string[] { RootPagePath };
                 
            }
            
            AddDateAndTypeColumns();
        }
 
 protected void ddlSite_SelectedIndexChanged(object sender, EventArgs e)
        {
            lblSiteName.Text = ddlSite.SelectedItem.Text;
            this.SiteID = Convert.ToInt32(ddlSite.SelectedValue);
 
            string RootPagePath = Page.ResolveUrl(String.Format("~/SiteData/{0}/UserFiles", this.SiteID));
            //Set initial folder to open. Note that the path is case sensitive!
            // FileExplorer1.InitialPath = PagePath;
            FileExplorer1.Configuration.ViewPaths = new string[] { RootPagePath };
            FileExplorer1.Configuration.UploadPaths = new string[] { RootPagePath };
            FileExplorer1.Configuration.DeletePaths = new string[] { RootPagePath };
        }

Thanks in advance for your help....

6 Answers, 1 is accepted

Sort by
0
dipan
Top achievements
Rank 1
answered on 17 Feb 2011, 06:19 AM
Hi,
I have solved the problem. Its working fine now.
0
Lori Beck
Top achievements
Rank 1
answered on 25 Feb 2011, 07:23 PM
Hi dipan,

Would you mind posting the solution you found?  I'm having the same problem.

Thank you!!
0
dipan
Top achievements
Rank 1
answered on 27 Feb 2011, 11:37 PM
Hi Lori,
The way I made it work is:
configure your file explorer in seperate function:
protected void ConfigureFileExplorer()
        {
            FileExplorer1.VisibleControls = GetVisibleControls();
            FileExplorer1.EnableOpenFile = true;
            FileExplorer1.DisplayUpFolderItem = true;
            FileExplorer1.AllowPaging = true;
            FileExplorer1.EnableCreateNewFolder = true;
            FileExplorer1.Upload.Enabled = true;
 
            this.SiteID = Convert.ToInt32(ddlSite.SelectedValue);
            string PagePath = Page.ResolveUrl(String.Format("~/SiteData/{0}/UserFiles/allowed.png", this.SiteID));
            string RootPagePath = Page.ResolveUrl(String.Format("~/SiteData/{0}/UserFiles", this.SiteID));
            string RootSharedFolder = Page.ResolveUrl("~/SiteData/SharedFolder");
            FileExplorer1.TreeView.Nodes.Clear();
            FileExplorer1.InitialPath = RootPagePath;
            FileExplorer1.Configuration.ViewPaths = new string[] { RootPagePath,RootSharedFolder};
            FileExplorer1.Configuration.UploadPaths = new string[] { RootPagePath,RootSharedFolder};
            FileExplorer1.Configuration.DeletePaths = new string[] { RootPagePath,RootSharedFolder};
            FileExplorer1.Configuration.MaxUploadFileSize = 20480 * 1024; // 20 MB
            FileExplorer1.Configuration.SearchPatterns = new string[] { "*.*" };
            FileExplorer1.PageSize = 20;
 
            FileExplorer1.Configuration.ContentProviderTypeName = typeof(CustomColumnsContentProvider).AssemblyQualifiedName;
 
 
            AddDateAndTypeColumns();
            AddCustomDownloadOption();
        }
 
then in page load
 
 protected void Page_Load(object sender, EventArgs e)
        {
            InitializeContainer();
            //set properties according to configuration panel
            
 
            if (!IsPostBack)
            {
                BindSite();
                lblInstruction.Text = "<ol><li>Choose a site to upload files.</li><li>To upload multiple files create a zip file and upload, it will unzip automatically.</li><li>Maximum upload file size 20MB.</li><li>Click on image to see the preview.</li></ol>";
            }
 
            lblSiteName.Text = ddlSite.SelectedItem.Text;
            ConfigureFileExplorer();
        }
 
and set the dropdown seleted value in dropdown selectedIndexChanged event
 protected void ddlSite_SelectedIndexChanged(object sender, EventArgs e)
        {
            lblSiteName.Text = ddlSite.SelectedItem.Text;
            this.SiteID = Convert.ToInt32(ddlSite.SelectedValue);
        }
0
Dobromir
Telerik team
answered on 28 Feb 2011, 05:57 PM
Hello,

The latest moment of the page lifecycle that ViewPaths, UploadPaths, DeletePaths properties can be configured to RadFileExplorer is the Page_Load event, and the Button_Click event occurs after that.

The recommended approach to set RadFileExplorer dynamically according another controls' action / value is:
  • In the Page_Load you need to check which control causes postback
  • Then, change the paths based on the clicked button. Please note that you need to clear the old nodes in order to force the RadFileExplorer to repopulate its content.

Please find attached to this post a sample page demonstrating the above mentioned approach.

Kind regards,
Dobromir
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Steve
Top achievements
Rank 1
answered on 02 Mar 2011, 08:28 PM
Hi, I am trying to do the same thing - change RadFileExplorer path dynamically. The issue I have is I need to change it to network folder(\\server\c$\dir\...)
I got the error below:
System.InvalidOperationException: Failed to map the path '/server/c$/dir/...

"\\" in my code is changed to "/
Any advice?
0
Dobromir
Telerik team
answered on 08 Mar 2011, 10:04 AM
Hi Steve,

In order to browser shared network folders using RadFileExplorer you need to implement custom filebrowser content provider. An example of such content provider is available in the following KB article:
Use RadFileExplorer with physical and shared folder's paths

Regards,
Dobromir
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
FileExplorer
Asked by
dipan
Top achievements
Rank 1
Answers by
dipan
Top achievements
Rank 1
Lori Beck
Top achievements
Rank 1
Dobromir
Telerik team
Steve
Top achievements
Rank 1
Share this question
or