Using the Image Manager Dialog to get images from a database

8 posts, 0 answers
  1. Roger Withnell
    Roger Withnell avatar
    36 posts
    Member since:
    Nov 2009

    Posted 25 Nov 2009 Link to this post

    I would like Image Manager to display a list of images from a database so that they can be inserted into the editor.

    I am using asp.net 3.5, Visual Web Developer 2008 Express and VB.

    I understand that to do this I need to build a Custom FileBrowserContent Provider as described in:

    http://www.telerik.com/help/aspnet-ajax/customfilebrowsercontentprovider.html

    I have created MyContentProvider class in MyCustomProvider namespace as per the above help page and added:

    <%@ Register Namespace = "MyCustomProvider" TagPrefix = "MyCp" Assembly="App_Code" %>

    But when I add:

    RadEditor1.ImageManager.ContentProviderTypeName = "ContentProviders.RadEditor.MyContentProvider, App_Code" to my code behind, the Image Manager page has the following error:

    Value cannot be null.
    Parameter name: type
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.ArgumentNullException: Value cannot be null.
    Parameter name: type

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

    Stack Trace:

    [ArgumentNullException: Value cannot be null.
    Parameter name: type]
       System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +7679178
       Telerik.Web.UI.RadFileExplorer.InitContentProvider(String selectedUrl) +226
       Telerik.Web.UI.RadFileExplorer.InitContentProvider() +138
       Telerik.Web.UI.RadFileExplorer.BindExplorer() +48
       Telerik.Web.UI.RadFileExplorer.OnLoad(EventArgs e) +139
       System.Web.UI.Control.LoadRecursive() +50
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

    I've also tried setting it with the example (from the Help page above):

    RadEditor1.FileBrowserContentProviderTypeName = typeof(DatabaseContentProvider).AssemblyQualifiedName

    but I don't know the VB syntax for this.

    Your help would be much appreciated.

    Thanking you in anticipation.

    Roger

     

  2. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 30 Nov 2009 Link to this post

    Hi Roger,

    In your case I recommend you use this approach in order to set the content provider to the RadEditor control:
    RadEditor1.FileBrowserContentProviderTypeName = GetType(DatabaseContentProvider).AssemblyQualifiedName

    I hope this helps.

    Regards,
    Fiko
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. humayoo
    humayoo avatar
    3 posts
    Member since:
    Oct 2010

    Posted 05 Sep 2011 Link to this post

    Hello,

    i am getting  error when i used 'Gettype' instead of 'typeof'. please see the attachment for error details.

    thanks
    Humayoo
  4. Rumen
    Admin
    Rumen avatar
    14031 posts

    Posted 05 Sep 2011 Link to this post

    Hello Humayoo,

    Have you tried the following syntax:

    ImageManagerParameters.FileBrowserContentProviderTypeName =
    typeof(Telerik.Web.Examples.DBContentProvider).AssemblyQualifiedName;

    Kind regards,
    Rumen
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  5. humayoo
    humayoo avatar
    3 posts
    Member since:
    Oct 2010

    Posted 05 Sep 2011 Link to this post

    Hi,

    if i used  "ImageManagerParameters.FileBrowserContentProviderTypeName = typeof(Telerik.Web.Examples.DBContentProvider).AssemblyQualifiedName;" , i get this error sometimes. please see attachment also  about error details.

    Server Error in '/myproject' Application.


    Value cannot be null.
    Parameter name: type

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.ArgumentNullException: Value cannot be null.
    Parameter name: type

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [ArgumentNullException: Value cannot be null.
    Parameter name: type]
       System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +7681290
       Telerik.Web.UI.RadFileExplorer.InitContentProvider(String selectedUrl) +228
       Telerik.Web.UI.RadFileExplorer.InitContentProvider() +140
       Telerik.Web.UI.RadFileExplorer.get_ContentProvider() +24
       Telerik.Web.UI.RadFileExplorer.BindExplorer() +48
       Telerik.Web.UI.RadFileExplorer.OnLoad(EventArgs e) +139
       System.Web.UI.Control.LoadRecursive() +50
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
    


    Version Information: Microsoft .NET Framework Version:2.0.50727.5446; ASP.NET Version:2.0.50727.5420


    here is my code for image manager
    DialogOpener DialogOpener1 =e.Item.FindControl("DialogOpener1") as DialogOpener;
                    FileManagerDialogParameters imageManagerParameters = new FileManagerDialogParameters();
                    imageManagerParameters.ViewPaths = new string[] { "~/imagefolder/A" };
                    imageManagerParameters.UploadPaths = new string[] { "~/imagefolder/A" };
                    imageManagerParameters.DeletePaths = new string[] { "~/imagefolder/A" };
                    imageManagerParameters.MaxUploadFileSize = 5242880;
                    imageManagerParameters.FileBrowserContentProviderTypeName = typeof(ChangeImageSizeProvider).AssemblyQualifiedName;
      
                    // If you don't set the following property, the default value will be used
                    imageManagerParameters.SearchPatterns = new string[] { "*.jpg", "*.gif", "*.png" };
      
                    DialogDefinition imageManager = new DialogDefinition(typeof(ImageManagerDialog), imageManagerParameters);
                    imageManager.ClientCallbackFunction = "ImageManagerFunction";
                    imageManager.Width = Unit.Pixel(750);
                    imageManager.Height = Unit.Pixel(440);
                    imageManager.Parameters["EnableImageEditor"] = false;
      
      
      
      
                    //If you need to customize the dialog then register the external dialog files
                    imageManager.Parameters["ExternalDialogsPath"] = "~/EditorDialogs/";
      
                    DialogOpener1.DialogDefinitions.Add("ImageManager", imageManager);
  6. Rumen
    Admin
    Rumen avatar
    14031 posts

    Posted 08 Sep 2011 Link to this post

    Hello Humayoo,

    Do you get the mentioned error when using the built-in content provider? Please, remove the
       imageManagerParameters.FileBrowserContentProviderTypeName = typeof(ChangeImageSizeProvider).AssemblyQualifiedName;
    line and test again.

    I also noticed that you have set the ExternalDialogsPath property and most likely you have customized the dialog. Please remove the imageManager.Parameters["ExternalDialogsPath"] = "~/EditorDialogs/"; line and see whether the customization is causing the problem.

    My suggestion is to also test your code with the latest version of RadControls for ASP.NET AJAX Q2 2011, where it could be fixed. Please, note that it does not support .NET 2.0 and you should test it with 3.5 or 4.0.

    Best regards,
    Rumen
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  7. humayoo
    humayoo avatar
    3 posts
    Member since:
    Oct 2010

    Posted 08 Sep 2011 Link to this post

    Hello,

     thanks for reply. i am using custom content provider. i can not use latest rad control because i am using sitefinity 3.7. this controls dll from sitefinity 3.7

    thanks
    Humayoo
  8. Rumen
    Admin
    Rumen avatar
    14031 posts

    Posted 13 Sep 2011 Link to this post

    Hello Humayoo,

    You can see how to upgrade to the latest version in Sitefinity in this KB article: How to upgrade RadControls. If you would like you can wait for Q2 2011 SP1 that will be released later this week.

    Best regards,
    Rumen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top