Multiple TextBoxes and File Explorer as Selector

3 posts, 0 answers
  1. Simon
    Simon avatar
    23 posts
    Member since:
    Apr 2009

    Posted 04 Mar 2010 Link to this post

    Dear All,
    This is my situation.  I have based my solution on this http://demos.telerik.com/aspnet-ajax/fileexplorer/examples/fileselectordialog/defaultcs.aspx tutorial.  I have created 5 other pages that hold the file explorer for selecting different images.

    Please see my code below.  I am trying to populate different text boxes based on different file selectors.  I can only get the last text box to populate with the file path and it ignores all the others.

    Any help Please!!!!

    <igtab:UltraWebTab ID="UltraWebTab1" runat="server" BorderColor="#949C9C" BorderStyle="Solid" 
                BorderWidth="1px" DisplayMode="Scrollable" Width="400px"  
                ThreeDEffect="False"
                <Tabs> 
                    <igtab:Tab Text="Small Product No" Tooltip="Small Product Number"
                        <ContentTemplate> 
                            <fieldset> 
                                <asp:Label ID="Image1Label" runat="server" /><br /> 
                                <asp:TextBox ID="File1" runat="server" /> 
                                <asp:Button OnClientClick="OpenFileExplorerDialog(); return false;" ID="SelectImage1Button" 
                                    runat="server" Text="Select" /> 
                                <asp:Button ID="upload1Button" runat="server" Text="Upload" OnClick="upload1Button_Click" /> 
                            </fieldset> 
                        </ContentTemplate> 
                    </igtab:Tab> 
                    <igtab:Tab Text="Large Product No" Tooltip="Large Product No"
                        <ContentTemplate> 
                            <fieldset> 
                                <asp:Label ID="Label1" runat="server" /><br /> 
                                <asp:TextBox ID="TextBox1" runat="server" /> 
                                <asp:Button OnClientClick="OpenFileExplorerDialog(); return false;" ID="Button2" 
                                    runat="server" Text="Select" /> 
                                <asp:Button ID="Button3" runat="server" Text="Upload" OnClick="upload1Button_Click" /> 
                            </fieldset> 
                        </ContentTemplate> 
                    </igtab:Tab> 
                    <igtab:Tab Text="Product Thumbnail" Tooltip="Product Thumbnail"
                    </igtab:Tab> 
                    <igtab:Tab Text="Large Product Image 1" Tooltip="Large Product Image 1"
                    </igtab:Tab> 
                    <igtab:Tab Text="Large Product Image 2" Tooltip="Large Product Image 2"
                    </igtab:Tab> 
                </Tabs> 
                <RoundedImage FillStyle="LeftMergedWithCenter" HoverImage="ig_tab_winXPs2.gif"  
                    LeftSideWidth="7" NormalImage="ig_tab_winXPs3.gif" RightSideWidth="6"  
                    SelectedImage="ig_tab_winXPs1.gif" ShiftOfImages="2" /> 
                <SelectedTabStyle> 
                    <Padding Bottom="2px" /> 
                </SelectedTabStyle> 
                <DefaultTabStyle BackColor="GhostWhite" Font-Names="Microsoft Sans Serif"  
                    Font-Size="8pt" ForeColor="Black" Height="22px"
                    <Padding Top="2px" /> 
                </DefaultTabStyle> 
            </igtab:UltraWebTab> 
     
            <script type="text/javascript"
                function OpenFileExplorerDialog() { 
                    var wnd = $find("<%= ExplorerWindow.ClientID %>"); 
                    wnd.show(); 
                } 
     
                //This function is called from the Explorer.aspx page 
                function OnFileSelected(wnd, fileSelected) { 
                    var textbox = $get("<%= File1.ClientID %>"); 
                    textbox.value = fileSelected
                } 
            </script> 
     
            <telerik:RadWindow runat="server" Width="650px" Height="560px" VisibleStatusbar="false" 
                Style="z-index: 101" NavigateUrl="~/Rebecca/FileExplorer/Image1.aspx" ID="ExplorerWindow" 
                Modal="true" Behaviors="Close,Move"
            </telerik:RadWindow> 
             
            <script type="text/javascript"
                function OpenLargeImage() { 
                    var wnd = $find("<%= RadWindow1.ClientID %>"); 
                    wnd.show(); 
                } 
     
                //This function is called from the Explorer.aspx page 
                function OnFileSelected(wnd, fileSelected) { 
                    var textbox1 = $get("<%= TextBox1.ClientID %>"); 
                    textbox1.value = fileSelected
                } 
            </script> 
     
            <telerik:RadWindow runat="server" Width="650px" Height="560px" VisibleStatusbar="false" 
                Style="z-index: 101" NavigateUrl="~/Rebecca/FileExplorer/LargeProductNo.aspx" ID="RadWindow1" 
                Modal="true" Behaviors="Close,Move"
            </telerik:RadWindow> 

  2. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 09 Mar 2010 Link to this post

    Hi Simon,

    The problem comes from the fact that you have more than one JavaScript method with the same name. Please note that in this case the last method will be executed. In your case I recommend you to change the names of the methods for example: OnFileSelected1 and OnFileSelected2. Then in the Explorer.aspx page you need to call the corresponding methods from the parent page (the code from the demo):
    function OnClientGridDblClick(sender, args)
    {
        var item = args.get_item();
     
        //If file (and not a folder) is selected - call the OnFileSelected method on the parent page
        if (item.get_type() == Telerik.Web.UI.FileExplorerItemType.File)
        {
            args.set_cancel(true);
            //Get a reference to the opener parent page using rad window
            var wnd = getRadWindow();
            var openerPage = wnd.BrowserWindow;
            //if you need the URL for the item, use get_url() instead of get_path()
            openerPage.OnFileSelected1(wnd, item.get_path());
            //Close window
            wnd.close();
        }
    }

    I hope this helps.

    Regards,
    Fiko
    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. Simon
    Simon avatar
    23 posts
    Member since:
    Apr 2009

    Posted 09 Mar 2010 Link to this post

    Thank you for pointing that out.  I can't believe I missed something sooo simple.

    Simon
Back to Top