Skip to main content
Tab

UploadControlFileUploadMode Enum

Lists values which specify when the file upload process is automatically executed on the server side.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.2.dll

Declaration

public enum UploadControlFileUploadMode

Members

Name Description
BeforePageLoad

Specifies that the file upload process is automatically executed before Page_Load event.

OnPageLoad

Specifies that the file upload process is automatically executed on Page_Load event.

Related API Members

The following properties accept/return UploadControlFileUploadMode values:

Remarks

The UploadControlFileUploadMode enumerator lists the values used to set the FileUploadMode property. The property specifies the moment of a page life cycle when the file upload should be performed. Note that after a file is uploaded, the page’s life cycle processing is broken, so subsequent page events are not raised.

Set the FileUploadMode property to BeforePageLoad to perform a file upload before a page controls hierarchy is rebuilt. In this case, you can simply upload a file without request to other controls on the page.

Set the FileUploadMode property to OnPageLoad to perform a file upload after page a controls hierarchy is rebuilt. In this case, you can upload a file using additional information from other controls on the page.

See the following topic for more information: Page Life Cycle During File Upload.

Run Demo: Upload and Submit

Example

This example demonstrates how ASPxUploadControl can get the information from other controls on the page in a file upload process (within FileUploadComplete event handler). Note that the FileUploadMode property must be set to OnPageLoad. In this case, a page hierarchy is rebuilt and control properties are available before the ASPxUploadControl requires them.

Select a painting:
<dx:ASPxUploadControl ID="ASPxUploadControl1" runat="server" ClientInstanceName="uploadControl" 
    OnFileUploadComplete="ASPxUploadControl1_FileUploadComplete" FileUploadMode="OnPageLoad" />

Select a genre of painting:
<dx:ASPxRadioButtonList ID="ASPxRadioButtonList1" runat="server" 
    ClientInstanceName="radioButtonList" SelectedIndex="0">
    <Items>
        <dx:ListEditItem Text="Portrait" Value="Portrait" Selected="True" />
        <dx:ListEditItem Text="Landscape" Value="Landscape" />
        <dx:ListEditItem Text="Still life" Value="Still life" />
    </Items>
</dx:ASPxRadioButtonList>

<dx:ASPxButton ID="ASPxButton1" runat="server" Text="Upload" AutoPostBack="False">
    <ClientSideEvents Click="function(s, e) 
        uploadControl.Upload();
    }" />
</dx:ASPxButton>
protected void ASPxUploadControl1_FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e) {
    string fileName = "D:/" + ASPxRadioButtonList1.Value + "/" + e.UploadedFile.FileName;
    e.UploadedFile.SaveAs(fileName);
}
See Also