Adding webforn value to upload name

Last post 02-20-2014, 7:29 PM by TimBall. 2 replies.
Sort Posts: Previous Next
  •  02-19-2014, 6:03 PM 79949

    Adding webforn value to upload name

     Is it possible to take a value from a dropdown menu on a web form and prepend that to the document name of the uploaded file.

     

    If I have the values A4, A3, A2 as sizes in a drop down menu and i select A3 when I select my document it automatically prepends to the file name

     

    eg. "A3_documentName.pdf" 

  •  02-20-2014, 8:40 AM 79953 in reply to 79949

    Re: Adding webforn value to upload name

    Hi TimBall,

     

    Please try the example below, it shows you how to achieve it. You can get the select value from the dropdown list and use in the FileUploaded event with the save file name.

     

    1. <%@ Page Language="C#" AutoEventWireup="True" %>  
    2.   
    3. <%@ Register Assembly="CuteWebUI.AjaxUploader" Namespace="CuteWebUI" TagPrefix="ajaxuploader" %>  
    4. <html>  
    5. <head>  
    6.     <script runat="server">  
    7.         protected void uploader1_FileUploaded(object sender, UploaderEventArgs args)  
    8.         {  
    9.             args.CopyTo("~/" + preName.SelectedValue + args.FileName);  
    10.         }  
    11.     </script>  
    12. </head>  
    13. <body>  
    14.     <form id="Form1" runat="server">  
    15.         <asp:DropDownList ID="preName" runat="server">  
    16.             <asp:ListItem Value="a3">A3</asp:ListItem>  
    17.             <asp:ListItem Value="a4">A4</asp:ListItem>  
    18.             <asp:ListItem Value="a5">A5</asp:ListItem>  
    19.         </asp:DropDownList>  
    20.         <CuteWebUI:UploadAttachments ID="uploader1" runat="server" OnFileUploaded="uploader1_FileUploaded">  
    21.         </CuteWebUI:UploadAttachments>  
    22.     </form>  
    23. </body>  
    24. </html>  
     

    Regards,

     

    Ken 

  •  02-20-2014, 7:29 PM 79958 in reply to 79953

    Re: Adding webforn value to upload name

     Hi Ken,

     

    Brilliant works like a charm :)

     

    Thanks very much.

View as RSS news feed in XML