FileUpload control cleared

I was having problems with the FileUpload control, and I was wondering if I could help.

On my page, I have a FileUpload control and a drop down list.

So, the user views the desired file, and then selects a parameter from the drop-down list (which allows you to use some flags that are also on the page used, depending on what they selected in the drop-down list). This will cause the FileUpload control to become empty, and now the user must navigate to the file they wanted again.

In any case, to prevent the FileUpload control from locking during PostBack?

+3
source share
7 answers

Since you tried Relster's suggestion, and it didn't work, Spencer is right. Due to security issues, it is impossible for anything other than the browser to set the path to the <input type = "file" /> element. The only solution is to restructure the stream, to only do the postback when you want to send the file, and do any other client script manipulations.

, , , . , , , , , , .

+7

, , autopostback, true, , ?

, .

+5

, , , .

, ajax , .

http://forums.asp.net/t/1125781.aspx

, :

"... AJAX , , DropDownList, , FileUpload, , FileUpload FilePath."

System.Web.Extensions.dll , ,.NET Framework 3.5.

+2

, , , , , . . ( ) . GMail .

, .

, , .

+1

. Ajax.

0
source

I wrapped my autopostback controls inside asp: updatepanel, and this took care of this, except for the validation error.

0
source

A simple solution to prevent the loss of the file with uploadcontrol, and postback - put uploadcontroloutside the control updatepanelon the .aspx page.

eg.

         <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
        <ajax:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
        </ajax:ToolkitScriptManager>
        <table>
    <tr>
    <td>
<asp:UpdatePanel runat="server" ID="Up_LeaveDetails" UpdateMode="Always">                                 
<ContentTemplate>
<asp:DropDownList ID="DDl_LeaveType" runat="server" CssClass="textfield" Width="150"
                                                                                    AutoPostBack="true" OnSelectedIndexChanged="DDl_LeaveType_SelectedIndexChanged">
                                                                                </asp:DropDownList>
</ContentTemplate>
 </asp:UpdatePanel>
</td>
    <td>
    <asp:FileUpload ID="UploadCertificate" runat="server" />
    </td>
    </tr>
        </table>
    </asp:Content>
0
source

Source: https://habr.com/ru/post/1712325/


All Articles