Accessing FileContentProvider Object

6 posts, 0 answers
  1. Samee Mir
    Samee Mir avatar
    26 posts
    Member since:
    Jan 2010

    Posted 09 Mar 2010 Link to this post

    hi.
    Can you please tell me how can i access the object of FileContentProvide with RadFileExplorer ?

    Regards,
    Samee Javaid        
  2. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 11 Mar 2010 Link to this post

    Hi Samee,

    By design, the RadFileExplorer control does not provide access to the content provider used. Could you please describe your scenario in details and / or provide a sample runnable project so we can investigate the case and get back to you with an appropriate solution?

    Sincerely yours,
    Dobromir
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Lester
    Lester avatar
    13 posts
    Member since:
    May 2009

    Posted 13 Mar 2010 Link to this post

    Hi.

    I am using your sample project about  DbContentProvider and need to connect the dbcontentprovider to pull data from many sqlservers.

    I understand that in this assignation

    RadFileExplorer1.Configuration.ContentProviderTypeName = typeof(Telerik.Web.Examples.DBContentProvider).AssemblyQualifiedName; 

    You setup this property to future binding of the assembly. Works fine if like in the sample, the dbconnection is taken from a fixed setting in web.confg.

    I need to this work dynamically, so, i need to pass the dbconnection in server code, i modified the code to send the new dbconnection in the searchpatterns property and works fine for the 1st time the sample runs

        protected void Page_Load(object sender, EventArgs e)
            {
                    RadFileExplorer1.Configuration.SearchPatterns = new string[] {  "datasource=" + addressbox.text + ";......." };
                    RadFileExplorer1.Configuration.ContentProviderTypeName = typeof(Telerik.Web.Examples.DBContentProvider).AssemblyQualifiedName;


    Buf if in another page load if the addressbox.text have another value, the fileexplorer ignores this new value. I understand that the problem is that this controls dont have a refresh() method and looking in the sample code, you always only validate if the underlying placeholder values are null one time and in that case instantiate the required object, but if i change the contentprovidertypename, the underlaying objects are already instantiated ( are not null ) so this new value is ignored.

    Line in the dbcontentprovider.cs file to check for dataserver instantiation

    private DataServer DataServer 
            { 
                get 
                { 
                    if (Object.Equals(_dataServer, null)) 
                    { 
                        _dataServer = new DataServer(ServerAddress, ClientRoot ); 
                    } 
                    return _dataServer; 
                } 
            } 


    If there is not a refresh() method that reload the entire contents (treeview & grid ), how can i subclass the radfileexplorer control to make the underlying internal variable that holds the instantiated object becomes null, or i assign it with a new instance of the custom content provider with a new address on it?

    With this little piece of code i know the name of the protected variables, but looks like i am creating a 2nd object instead of overwriting the one i want

            protected class testFE : RadFileExplorer 
            { 
                public void X(  ) 
                { 
                     
                    this.ContentProvider = null
                } 
            } 
     
            protected void Page_Load(object sender, EventArgs e) 
            { 
     
               RadFileExplorer1.Configuration.SearchPatterns = new string[] { "Datasource=" + Addressbox.text + "......." }; 
               RadFileExplorer1.Configuration.ContentProviderTypeName =              typeof(Telerik.Web.Examples.DBContentProvider).AssemblyQualifiedName; 
               testFE b = new testFE(); 
               b.X(); 
     


    Any idea where can i achieve this refresh ?

    LEster


  5. Lini
    Admin
    Lini avatar
    2144 posts

    Posted 15 Mar 2010 Link to this post

    Hello Lester,

    If you think that the DataServer object is not being updated properly after changing the connection string, try modifying the content provider code and add a check if the connection string has changed. For example:

    private DataServer _dataServer;
    private string _dataConnectionString;
    private DataServer DataServer
    {
        get
        {
            if (_dataConnectionString != ConnectionString)
            {
                _dataServer = null;
            }
            if (Object.Equals(_dataServer, null))
            {
                _dataConnectionString = ConnectionString;
                _dataServer = new DataServer(_dataConnectionString);
            }
     
            return _dataServer;
        }
    }

    This way the object will be recreated each time the ConnectionString changes.

    Another solution can be to subclass the RadFileExplorer control override the ContentProvider property. This way you can check that you have the correct connection each time it is accessed and change it if necessary.

    Regards,
    Lini
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  6. Lester
    Lester avatar
    13 posts
    Member since:
    May 2009

    Posted 15 Mar 2010 Link to this post

    Hello. Lini

    Any clue about the subclassng option ? that is what i am trying to do. But it creates me another object, cant use the instantiated control defined in the aspx part.


  7. Lini
    Admin
    Lini avatar
    2144 posts

    Posted 16 Mar 2010 Link to this post

    Hello Lester,

    Here is a sample class you can place in the App_Code folder of your web site and then use on the page instead of the original file explorer:

    (place in App_Code)
    namespace mynamespace
    {
        public class myExplorer : Telerik.Web.UI.RadFileExplorer
        {
            protected override Telerik.Web.UI.Widgets.FileBrowserContentProvider ContentProvider
            {
                get
                {
                    //add custom code here to check and update the content provider depending on connection string
                    return base.ContentProvider;
                }
                set
                {
                    base.ContentProvider = value;
                }
            }
        }
    }

    (sample usage in ASPX page)
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
    <%@ Register Assembly="App_Code" Namespace="mynamespace" TagPrefix="myControls" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtm">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
    <myControls:myExplorer ID="RadFileExplorer1" runat="server">
    </myControls:myExplorer>
    ...

    You can then reference the RadFileExplorer1 control in your code just the same as you would a normal telerik file explorer.

    Regards,
    Lini
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017