Following is the Jquery code for the change event whenever the file uploaded or changed.
var document1FileUpload = $('#Document1FileUpload'); var fileNameTextBox1= $('#fileNameTextBox1'); document1FileUpload.die(); document1FileUpload.live('change', function () { console.log("1 Doc up"); if (this.files != undefined || this.files != null) { fileNameTextBox1.val(this.files[0].name); console.log("If block"); } else { var filePath = this.value.split("\\"); fileNameTextBox1.attr('value', filePath[filePath.length - 1]); console.log("else block"); } });
below is the designer code:
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <Triggers> <asp:PostBackTrigger ControlID="BulkUploadButton" /> </Triggers> <ContentTemplate> <table style="width:100%;"> <tr> <td style="width:5em;"> <web:Label AssociatedControlID="Document1FileUpload" Font-Size="X-Small" Text="File.1" runat="server" style="padding-left:0px;"/> <br /> <asp:FileUpload runat="server" ID="Document1FileUpload"/> </td> <td style="width:5em;"> <web:Label AssociatedControlID="DocumentTypeDropdownList1" Font-Size="X-Small" Text="Type.1" runat="server" style="padding-left:0px;"/> <br /> <web:DropDownList runat="server" ID="DocumentTypeDropdownList1" Width="100px" Height="20px"></web:DropDownList> </td> <td style="width:250px;"> <web:Label AssociatedControlID="FileNameTextBox1" Font-Size="X-Small" Text="File Name.1" runat="server" style="padding-left:0px;"/><br /> <web:TextBox ID="FileNameTextBox1" runat="server" MaxLength="150" TextMode="SingleLine" Width="250px" Height="20px" OrgValue="" /> </td> <td style="width:300px;" > <web:Label AssociatedControlID="Description1TextBox" Font-Size="X-Small" Text="Description.1" runat="server" style="padding-left:0px;" /><br /> <web:TextBox ID="Description1TextBox" runat="server" MaxLength="250" TextMode="SingleLine" Width="100%" Height="20px" /> </td> </tr> </table> </ContentTemplate> </asp:UpdatePanel>
The problem is when ever the file upload change event occurs the Description text does not update with respected file name. I also mention the file name as well as written to change the value according to the jquery coding standard. Please any help on this topic is much appreciated. Thanks fellow fantastic coder.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)