aspnet-devexpress-dot-web-dot-aspxuploadcontrol-96c4c546.md
Gets or sets a value that specifies when the file upload should be performed.
Namespace : DevExpress.Web
Assembly : DevExpress.Web.v25.2.dll
NuGet Package : DevExpress.Web
[DefaultValue(UploadControlFileUploadMode.BeforePageLoad)]
public UploadControlFileUploadMode FileUploadMode { get; set; }
<DefaultValue(UploadControlFileUploadMode.BeforePageLoad)>
Public Property FileUploadMode As UploadControlFileUploadMode
| Type | Default | Description |
|---|---|---|
| UploadControlFileUploadMode | BeforePageLoad |
One of the UploadControlFileUploadMode enumeration values.
|
Available values:
| 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.
|
The FileUploadMode property controls whether the file upload is performed on the server side, either during a server Page_Load event (the OnPageLoad value), or before a server Page_Load event ( the BeforePageLoad value).
When the FileUploadMode property is set to the default BeforePageLoad value, a file is uploaded and the request execution is aborted before the Page_Init method is called. Thus, controls are not initialized and not available in file upload events. Set the FileUploadMode property to OnPageLoad to rebuild the page hierarchy before the ASPxUploadControl requires them. In this case, control properties are available in file upload events.
This example demonstrates how ASPxUploadControl can get the information from other controls on the page in a file upload process (within ASPxUploadControl.FileUploadComplete event handler). Note that the ASPxUploadControl.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.
protected void ASPxUploadControl1_FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e) {
string fileName = "D:/" + ASPxRadioButtonList1.Value + "/" + e.UploadedFile.FileName;
e.UploadedFile.SaveAs(fileName);
}
Protected Sub ASPxUploadControl1_FileUploadComplete(sender As Object, e As DevExpress.Web.FileUploadCompleteEventArgs)
Dim fileName As String = "D:/" + ASPxRadioButtonList1.Value + "/" + Convert.ToString(e.UploadedFile.FileName)
e.UploadedFile.SaveAs(fileName)
End Sub
Select a painting:
<dx:ASPxUploadControl ID="ASPxUploadControl1" runat="server" ClientInstanceName="uploadControl" OnFileUploadComplete="ASPxUploadControl1_FileUploadComplete" FileUploadMode="OnPageLoad">
</dx:ASPxUploadControl>
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>
See Also