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

How to pass a selected filename to another control

2 Answers 146 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
dean.carrefour
Top achievements
Rank 1
dean.carrefour asked on 08 Dec 2010, 11:31 PM
I know the file explorer is an ASP.NET control, but much of the code needed is javascript and I'm just not any good with that.  So here's my noob question.  I have a video player control that embeds a windows media player on my page.  I have a File Explorer control above it showing the contents of a Video Library folder where the user is asked to double-click a filename and I want it to play in my video player.  From the OnClientItemSelected(sender, args) javascript function, can I call a function in my ASP code-behind page? Or is there a simpler/easier way to do this?  I need to take the selected filename and fill in the 'VideoURL' field of the video player control.

I have tried several different ways to do this with no luck and I'm getting frustrated.  I know this should be a simple task but I just don't get it.

Here is the code in my primary .aspx page.  There is nothing in the .aspx.vb page yet.

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
   <script type="text/javascript">
       
       function OnClientItemSelected(sender, args) {
           var vidpath = args.get_item().get_name();
           PlayVid(vidpath);
       }

    </script>


    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>

        Select a file below to view it.<br /><br />


        <telerik:RadFileExplorer
            ID="RadFileExplorer1" 
            runat="server" 
            Height="250px" 
            InitialPath="/VideoLibrary" Skin="Outlook" EnableCreateNewFolder="False" 
            ToolTip="Double-click a video from the list to view it." TreePaneWidth="0px" 
            VisibleControls="Grid, ContextMenus" 
            onclientitemselected="OnClientItemSelected" Width="606px">
                <Configuration SearchPatterns="*.*" 
                ViewPaths="/VideoLibrary">
                </Configuration>
        </telerik:RadFileExplorer>

        <br /><br />

    <ASPNetVideo:WindowsMedia ID="WindowsMedia1" runat="server" Height="480px" 
            VideoURL="http://www.pdcrx.com/VideoLibrary/Introduction_to_Palliative_Sedation_-_Aug_2010.wmv" 
            Width="640px" WMode="Window">
    </ASPNetVideo:WindowsMedia>

    </form>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
   <script type="text/javascript">
       
       function OnClientItemSelected(sender, args) {
           var vidpath = args.get_item().get_name();
           PlayVid(vidpath);
       }

    </script>


    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>

        Select a file below to view it.<br /><br />


        <telerik:RadFileExplorer
            ID="RadFileExplorer1" 
            runat="server" 
            Height="250px" 
            InitialPath="/VideoLibrary" Skin="Outlook" EnableCreateNewFolder="False" 
            ToolTip="Double-click a video from the list to view it." TreePaneWidth="0px" 
            VisibleControls="Grid, ContextMenus" 
            onclientitemselected="OnClientItemSelected" Width="606px">
                <Configuration SearchPatterns="*.*" 
                ViewPaths="/VideoLibrary">
                </Configuration>
        </telerik:RadFileExplorer>

        <br /><br />

    <ASPNetVideo:WindowsMedia ID="WindowsMedia1" runat="server" Height="480px" 
            VideoURL="http://www.pdcrx.com/VideoLibrary/Introduction_to_Palliative_Sedation_-_Aug_2010.wmv" 
            Width="640px" WMode="Window">
    </ASPNetVideo:WindowsMedia>

    </form>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
   <script type="text/javascript">
       
       function OnClientItemSelected(sender, args) {
           var vidpath = args.get_item().get_name();
           PlayVid(vidpath);
       }

    </script>


    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>

        Select a file below to view it.<br /><br />


        <telerik:RadFileExplorer
            ID="RadFileExplorer1" 
            runat="server" 
            Height="250px" 
            InitialPath="/VideoLibrary" Skin="Outlook" EnableCreateNewFolder="False" 
            ToolTip="Double-click a video from the list to view it." TreePaneWidth="0px" 
            VisibleControls="Grid, ContextMenus" 
            onclientitemselected="OnClientItemSelected" Width="606px">
                <Configuration SearchPatterns="*.*" 
                ViewPaths="/VideoLibrary">
                </Configuration>
        </telerik:RadFileExplorer>

        <br /><br />

    <ASPNetVideo:WindowsMedia ID="WindowsMedia1" runat="server" Height="480px" 
            VideoURL="http://www.pdcrx.com/VideoLibrary/Introduction_to_Palliative_Sedation_-_Aug_2010.wmv" 
            Width="640px" WMode="Window">
    </ASPNetVideo:WindowsMedia>

    </form>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
   <script type="text/javascript">
        
       function OnClientItemSelected(sender, args) {
           var vidpath = args.get_item().get_name();
           PlayVid(vidpath);  <-- This is where I was thinking of calling a code-behind vb function
       }
 
    </script>
 
 
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
 
        Select a file below to view it.<br /><br />
 
 
        <telerik:RadFileExplorer
            ID="RadFileExplorer1"
            runat="server"
            Height="250px"
            InitialPath="/VideoLibrary" Skin="Outlook" EnableCreateNewFolder="False"
            ToolTip="Double-click a video from the list to view it." TreePaneWidth="0px"
            VisibleControls="Grid, ContextMenus"
            onclientitemselected="OnClientItemSelected" Width="606px">
                <Configuration SearchPatterns="*.*"
                ViewPaths="/VideoLibrary">
                </Configuration>
        </telerik:RadFileExplorer>
 
        <br /><br />
 
    <ASPNetVideo:WindowsMedia ID="WindowsMedia1" runat="server" Height="480px"
            VideoURL="some_video_title.wmv"
            Width="640px" WMode="Window">
    </ASPNetVideo:WindowsMedia>
 
    </form>
</asp:Content>

2 Answers, 1 is accepted

Sort by
0
dean.carrefour
Top achievements
Rank 1
answered on 09 Dec 2010, 08:45 PM
No one can help me with this?  I know it should be a very simple task for someone familiar with this control.
0
Dobromir
Telerik team
answered on 10 Dec 2010, 03:25 PM
Hi Dean,

I am not quite sure I understand the question.

If you are asking if using OnClientItemSelected is the correct event to pass the name of the selected item, yes you can use this event, however, I would recommend you to use OnClientFileOpen event which is fired upon double click on a item, e.g.:
<telerik:RadFileExplorer ID="RadFileExplorer1" runat="server" OnClientFileOpen="OnClientFileOpen">
    <Configuration ViewPaths="~/ROOT" UploadPaths="~/ROOT" DeletePaths="~/ROOT" />
</telerik:RadFileExplorer>
 
<script type="text/javascript">
    function OnClientFileOpen(oExplorer, args)
    {
        var item = args.get_item();
 
        //check if the opened item is a file
        //if the item does not have extension it is a directory
        //you can add additional check if the file has specific extension
        if (item.get_extension())
        {
            args.set_cancel(true); //cancel the default execution
 
            var name = item.get_name(); //you can use get_path() method to get full path to the item
                                       alert(name);
            //execute the custom function changing the video in the MediaPlayer control
        }
         
    }
</script>

If you are asking how to call server-side method using JavaScript, you can use RadAjaxManager to invoke an ajax request to execute the server-side method, or you can use a static  WebMethod.

Best wishes,
Dobromir
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
FileExplorer
Asked by
dean.carrefour
Top achievements
Rank 1
Answers by
dean.carrefour
Top achievements
Rank 1
Dobromir
Telerik team
Share this question
or