File Selector Dialog - Databound Text Box

2 posts, 0 answers
  1. bslaght
    bslaght avatar
    184 posts
    Member since:
    Jun 2006

    Posted 04 May 2009 Link to this post

    I would like to use the file selector dialog demo to store the file path in a databound text box in a formview.

    My current code looks like this.  How can I change it to store the path in my databound file location textbox?

    1 <asp:FormView ID="fvAddBidDoc" runat="server" DataKeyNames="id" DataSourceID="dsAddBidDoc" 
    2         DefaultMode="Insert">  
    3  
    4         <InsertItemTemplate> 
    5             <table class="style1">  
    6                 <tr> 
    7                     <td> 
    8                         Document Number:</td> 
    9                     <td> 
    10                         <asp:TextBox ID="DocumentNumberTextBox" runat="server"   
    11                             Text='<%# Bind("DocumentNumber") %>' /> 
    12                     </td> 
    13                     <td> 
    14                         Document Name:</td> 
    15                     <td> 
    16                         <asp:TextBox ID="DocumentNameTextBox" runat="server"   
    17                             Text='<%# Bind("DocumentName") %>' /> 
    18                     </td> 
    19                 </tr> 
    20                 <tr> 
    21                     <td> 
    22                         Posting Date:  
    23                         <%--<asp:TextBox ID="PostingDateTextBox" runat="server" Text='<%# Bind("PostingDate") %>' />--%></td>  
    24                     <td> 
    25                         <telerik:RadDatePicker ID="PostingDateTextBox" Runat="server"   
    26                             DbSelectedDate='<%# Bind("PostingDate") %>' Skin="Hay">  
    27                             <Calendar Skin="Hay" UseColumnHeadersAsSelectors="False"   
    28                                 UseRowHeadersAsSelectors="False" ViewSelectorText="x">  
    29                             </Calendar> 
    30                             <DatePopupButton HoverImageUrl="" ImageUrl="" /> 
    31                         </telerik:RadDatePicker> 
    32                     </td> 
    33                     <td> 
    34                         Closing Date:  
    35                     </td> 
    36                     <td> 
    37                         <telerik:RadDatePicker ID="ClosingDateTextBox" Runat="server"   
    38                             DbSelectedDate='<%# Bind("ClosingDate") %>' Skin="Hay">  
    39                             <Calendar Skin="Hay" UseColumnHeadersAsSelectors="False"   
    40                                 UseRowHeadersAsSelectors="False" ViewSelectorText="x">  
    41                             </Calendar> 
    42                             <DatePopupButton HoverImageUrl="" ImageUrl="" /> 
    43                         </telerik:RadDatePicker> 
    44                     </td> 
    45                 </tr> 
    46                 <tr> 
    47                     <td> 
    48                         File Location:</td> 
    49                     <td> 
    50                         <asp:TextBox ID="FileLocationTextBox" runat="server"   
    51                             Text='<%# Bind("FileLocation") %>' /> 
    52                     </td> 
    53                     <td> 
    54                         Select a file:  
    55                     </td> 
    56                     <td> 
    57                         <input ID="fileName" size="50" /><input   
    58                             onclick="OpenFileExplorerDialog(); return false;" type="button"   
    59                             value="Open ..." /><br /> 
    60                         Open the dialog and double click on a file to select it.  
    61  
    62                         <script type="text/javascript">  
    63  
    64                 function OpenFileExplorerDialog() {  
    65                     var wnd = $find('<%=fvAddBidDoc.FindControl("ExplorerWindow").ClientID %>');  
    66                     wnd.show();  
    67                 }  
    68  
    69                 //This function is called from the Explorer.aspx page  
    70                 function OnFileSelected(wnd, fileSelected) {  
    71                     var textbox = $get("fileName");  
    72                     textbox.value = fileSelected;  
    73                 }  
    74             </script> 
    75  
    76                     </td> 
    77                 </tr> 
    78                 <tr> 
    79                     <td> 
    80                         <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"   
    81                             CommandName="Insert" Text="Insert" /> 
    82                     </td> 
    83                     <td> 
    84                         <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False"   
    85                             CommandName="Cancel" Text="Cancel" /> 
    86                     </td> 
    87                     <td> 
    88                         &nbsp;</td> 
    89                     <td> 
    90                         &nbsp;</td> 
    91                 </tr> 
    92             </table> 
    93             <br /> 
    94               
    95  
    96             <telerik:RadWindow runat="server" Width="530px" Height="550px" VisibleStatusbar="false" 
    97                 NavigateUrl="~/bidding/secure/explorer.aspx" ID="ExplorerWindow" Modal="true" 
    98                 Behaviors="Close,Move">  
    99             </telerik:RadWindow> 
    100             &nbsp;  
    101         </InsertItemTemplate> 
    102     
    103     </asp:FormView> 

    Thanks
    Brett
  2. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 05 May 2009 Link to this post

    Hi Bslaght,

    You can achieve the desired result such as in the online demo, but you need to get a reference to that text box first. This is a common ASP.NET task and for your convenience I pasted the modified OnFileSelected function below :

    //This function is called from the Explorer.aspx page   
    function OnFileSelected(wnd, fileSelected) 
        var textbox = $get('<%= fvAddBidDoc.FindControl("FileLocationTextBox").ClientID %>'); 
        textbox.value = fileSelected; 
    }  

    I hope this helps.

    All the best,
    Fiko
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top