Dialog opener - Independent files manager

5 posts, 0 answers
  1. אלון
    אלון avatar
    1 posts
    Member since:
    Sep 2006

    Posted 06 Dec 2008 Link to this post

    Requirements

    RadControls version

    2008.3 1125

    .NET version

    3.5

    Visual Studio version

    VS 2008

    programming language

    C Sharp

    browser support

    all browsers supported by RadControls


    PROJECT DESCRIPTION

    Attached is a demo project referring the independent file manager.
    In this demo I refine the use of image and documents manager dialogs outside RADEditor for ASP.NET AJAX so it will support multi images/documents in a single page.


    App_Code --> DialogOpenerHandler.cs

    1  
     
    3 public static class DialogOpenerHandler  
    4 {  
    5     public static void SetDocumentDialog(DialogOpener dialogOpener, string baseUrl)  
    6     {  
    7         FileManagerDialogParameters documentManagerParameters = new FileManagerDialogParameters();  
    8         documentManagerParameters.ViewPaths = new string[] { baseUrl };  
    9         documentManagerParameters.UploadPaths = new string[] { baseUrl };  
    10         documentManagerParameters.DeletePaths = new string[] { baseUrl };  
    11         documentManagerParameters.MaxUploadFileSize = 5000000;  
    12  
    13  
    14         DialogDefinition documentManager = new DialogDefinition(typeof(DocumentManagerDialog), documentManagerParameters);  
    15         documentManager.ClientCallbackFunction = "DocumentManagerFunction";  
    16         documentManager.Width = System.Web.UI.WebControls.Unit.Pixel(694);  
    17         documentManager.Height = System.Web.UI.WebControls.Unit.Pixel(440);  
    18  
    19         dialogOpener.DialogDefinitions.Add("DocumentManager", documentManager);  
    20     }  
    21  
    22     public static void SetFlashDialog(DialogOpener dialogOpener, string baseUrl)  
    23     {  
    24         FileManagerDialogParameters documentManagerParameters = new FileManagerDialogParameters();  
    25         documentManagerParameters.ViewPaths = new string[] { baseUrl };  
    26         documentManagerParameters.UploadPaths = new string[] { baseUrl };  
    27         documentManagerParameters.DeletePaths = new string[] { baseUrl };  
    28         documentManagerParameters.MaxUploadFileSize = 5000000;  
    29  
    30  
    31         DialogDefinition documentManager = new DialogDefinition(typeof(FlashManagerDialog), documentManagerParameters);  
    32         documentManager.ClientCallbackFunction = "FlashManagerFunction";  
    33         documentManager.Width = System.Web.UI.WebControls.Unit.Pixel(694);  
    34         documentManager.Height = System.Web.UI.WebControls.Unit.Pixel(440);  
    35  
    36         dialogOpener.DialogDefinitions.Add("FlashManager", documentManager);  
    37     }  
    38  
    39     public static void SetImageDialog(DialogOpener dialogOpener, string baseUrl)  
    40     {  
    41         FileManagerDialogParameters imageManagerParameters = new FileManagerDialogParameters();  
    42         imageManagerParameters.ViewPaths = new string[] { baseUrl };  
    43         imageManagerParameters.UploadPaths = new string[] { baseUrl };  
    44         imageManagerParameters.DeletePaths = new string[] { baseUrl };  
    45         imageManagerParameters.MaxUploadFileSize = 5000000;  
    46         // If you don't set the following property, the default value will be used     
    47         // imageManagerParameters.SearchPatterns = new string[] { "*.jpg" };     
    48         DialogDefinition imageManager = new DialogDefinition(typeof(ImageManagerDialog), imageManagerParameters);  
    49         imageManager.ClientCallbackFunction = "ImageManagerFunction";  
    50         imageManager.Width = System.Web.UI.WebControls.Unit.Pixel(694);  
    51         imageManager.Height = System.Web.UI.WebControls.Unit.Pixel(440);  
    52  
    53         dialogOpener.DialogDefinitions.Add("ImageManager", imageManager);  
    54  
    55         FileManagerDialogParameters imageEditorParameters = new FileManagerDialogParameters();  
    56         imageEditorParameters.ViewPaths = new string[] { baseUrl };  
    57         imageEditorParameters.UploadPaths = new string[] { baseUrl };  
    58         imageEditorParameters.DeletePaths = new string[] { baseUrl };  
    59         imageEditorParameters.MaxUploadFileSize = 5000000;  
    60  
    61         DialogDefinition imageEditor = new DialogDefinition(typeof(ImageEditorDialog), imageEditorParameters);  
    62         imageEditor.Width = System.Web.UI.WebControls.Unit.Pixel(832);  
    63         imageEditor.Height = System.Web.UI.WebControls.Unit.Pixel(520);  
    64         dialogOpener.DialogDefinitions.Add("ImageEditor", imageEditor);  
    65  
    66     }  
    67

    JScrips --> FileManager.js


    1 var callBackControl = "";  
    2  
    3 function OpenDialog(currentCallBackControl, dialog, type)   
    4 {  
    5     callBackControl = currentCallBackControl;  
    6     $find(dialog).open(type);   
    7 }  
    8  
    9 function ImageManagerFunction(sender, args)   
    10 {  
    11     var selectedItem = args.SelectedItem;  
    12     var resultImageObject = args.Result;  
    13  
    14     var txt = $get(callBackControl);  
    15     if (document.all)   
    16     {  
    17         txt.value = selectedItem.getPath();  
    18     }  
    19     else   
    20     {  
    21         txt.value = selectedItem.getPath();  
    22     }  
    23 }  
    24 function DocumentManagerFunction(sender, args)   
    25 {  
    26     var selectedItem = args.SelectedItem;  
    27     var resultDocumentObject = args.Result;  
    28  
    29     var txt = $get(callBackControl);  
    30     if (document.all)   
    31     {  
    32         txt.value = selectedItem.getPath(); ;  
    33     }  
    34     else   
    35     {  
    36         txt.value = selectedItem.getPath();  
    37     }  
    38 }  
    39 function FlashManagerFunction(sender, args)   
    40 {  
    41     var selectedItem = args.SelectedItem;  
    42     var resultDocumentObject = args.Result;  
    43     var txt = $get(callBackControl);  
    44  
    45     if (document.all)   
    46     {  
    47         txt.value = selectedItem.getPath();  
    48     }  
    49     else   
    50     {  
    51         txt.value = selectedItem.getPath();  
    52     }  
    53 }   

    Default.aspx

    1 <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %> 
    2  
    3 <%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> 
    4  
    5 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    6  
    7 <html xmlns="http://www.w3.org/1999/xhtml">  
    8 <head runat="server">  
    9     <title></title>  
    10     <script src="JScrips/FileManager.js" type="text/javascript"></script> 
    11 </head> 
    12 <body> 
    13     <form id="form1" runat="server">  
    14     <asp:ScriptManager ID="ScriptManager1" runat="server">  
    15     </asp:ScriptManager> 
    16     <div> 
    17         <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" Skin="Vista" /> 
    18         <asp:TextBox runat="server" ID="ImageTextBox1" Width="400px"></asp:TextBox><button onclick="OpenDialog('ImageTextBox1', 'DialogOpener1', 'ImageManager');return false;">Open ImageManager1</button><br />    
    19         <asp:TextBox runat="server" ID="ImageTextBox2" Width="400px"></asp:TextBox><button onclick="OpenDialog('ImageTextBox2', 'DialogOpener1', 'ImageManager');return false;">Open ImageManager2</button><br />    
    20         <asp:TextBox runat="server" ID="ImageTextBox3" Width="400px"></asp:TextBox><button onclick="OpenDialog('ImageTextBox3', 'DialogOpener1', 'ImageManager');return false;">Open ImageManager3</button><br />    
    21         <telerik:dialogopener runat="server" id="DialogOpener1" Skin="Telerik"></telerik:dialogopener>    
    22         <br /> 
    23         <button onclick="OpenDialog('ImageTextBox1', 'DialogOpener1', 'DocumentManager');return false;">Open Document Manager</button>    
    24         <button onclick="OpenDialog('ImageTextBox1', 'DialogOpener1', 'FlashManager');return false;">Open Flash Manager</button>    
    25  
    26     </div> 
    27     </form> 
    28 </body> 
    29 </html> 


    Default.aspx.cs

    1 using System;  
    2 using System.Collections.Generic;  
    3 using System.Linq;  
    4 using System.Web;  
    5 using System.Web.UI;  
    6 using System.Web.UI.WebControls;  
    7  
    8  
    9 public partial class _Default : System.Web.UI.Page   
    10 {  
    11     protected void Page_Load(object sender, EventArgs e)  
    12     {  
    13         DialogOpenerHandler.SetFlashDialog(DialogOpener1, "~/Upload/Flash");  
    14         DialogOpenerHandler.SetDocumentDialog(DialogOpener1, "~/Upload/Documents");  
    15         DialogOpenerHandler.SetImageDialog(DialogOpener1, "~/Upload/Images");  
    16     }  
    17       
    18 }  
    19  




  2. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 09 Dec 2008 Link to this post

    Hi Alon,

    Thank you for sharing your code solution with our community. We do appreciate your work and I updated your Telerik points.

    Best regards,
    Rumen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 26 Mar 2009 Link to this post

    Hi guys,

    In the Q1 2009 version of RadControls for ASP.NET AJAX, we streamlined the DialogOpener client-side API and the code provided in this code library will not work with the new version. You can see how to use the Image and Document managers in the Q1 2009 release as standalone controls in this KB article:

    Using the Image and Document managers outside RadEditor.

    All the best,
    Rumen
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  4. J
    J avatar
    5 posts
    Member since:
    Aug 2012

    Posted 06 Sep 2012 Link to this post

    Hi Rumen, 

    Have you tried running that demo (http://www.telerik.com/support/kb/aspnet-ajax/editor/using-the-image-and-document-managers-outside-radeditor.aspx) lately? 

    Using Telerik.Web.UI, v.2012.2.724.40, only the ImageEditor will open, where the ImageManager and DocumentManager give me

    "

    Object reference not set to an instance of an object.

    Stack Trace:

    [NullReferenceException: Object reference not set to an instance of an object.]
       Telerik.Web.UI.Editor.DialogControls.DocumentManagerDialog.OnLoad(EventArgs e) +146
       System.Web.UI.Control.LoadRecursive() +74
       System.Web.UI.Control.LoadRecursive() +146
       System.Web.UI.Control.LoadRecursive() +146
       System.Web.UI.Control.LoadRecursive() +146
       System.Web.UI.Control.LoadRecursive() +146
       System.Web.UI.Control.LoadRecursive() +146
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
    

    "
  5. J
    J avatar
    5 posts
    Member since:
    Aug 2012

    Posted 06 Sep 2012 Link to this post

Back to Top