Dynamically set path

7 posts, 0 answers
  1. dipan
    dipan avatar
    9 posts
    Member since:
    Feb 2010

    Posted 16 Feb 2011 Link to this post

    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....
  2. dipan
    dipan avatar
    9 posts
    Member since:
    Feb 2010

    Posted 17 Feb 2011 Link to this post

    Hi,
    I have solved the problem. Its working fine now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Lori Beck
    Lori Beck avatar
    1 posts
    Member since:
    Feb 2006

    Posted 25 Feb 2011 Link to this post

    Hi dipan,

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

    Thank you!!
  5. dipan
    dipan avatar
    9 posts
    Member since:
    Feb 2010

    Posted 27 Feb 2011 Link to this post

    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);
            }
  6. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 28 Feb 2011 Link to this post

    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!
  7. Steve
    Steve avatar
    2 posts
    Member since:
    Feb 2011

    Posted 02 Mar 2011 Link to this post

    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?
  8. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 08 Mar 2011 Link to this post

    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!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017