Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
  [Expand]Reporting
  [Expand]Chart Control
  [Expand]Grid View
  [Expand]Card View
  [Expand]Vertical Grid
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Image and Data Browsing
  [Expand]Docking and Popups
  [Expand]Site Navigation and Layout
  [Collapse]File Management
   [Expand]Product Information
   [Expand]File Manager
   [Collapse]File Upload
     ASPxUploadControl Overview
    [Collapse]Concepts (ASPxUploadControl)
      Upload Modes
      Allowed Content Types
      Uploading Large Files
      Multi-File Selection
      Appearance Customization
      Drag and Drop Support
      Page Life Cycle During File Upload
    [Expand]Visual Elements
  [Expand]Multi-Use Site Controls
  [Expand]Scheduler
  [Expand]HTML Editor
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gauges
  [Expand]Data Editors
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Localization
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Page Life Cycle During File Upload

When a file is being uploaded by ASPxUploadControl on the server side, the ASP.NET page life cycle is changed. After a file is uploaded and file upload events (ASPxUploadControl.FileUploadComplete and ASPxUploadControl.FilesUploadComplete) are raised, the request execution is aborted and only the Unload event is raised (see the diagram below).

Since file upload can be performed on two different control events (based on the ASPxUploadControl.FileUploadMode property value), there are two alternative page life cycles during file upload (illustrated in gold and green in the diagram below).

In the image above, the blue line illustrates a standard page life cycle. The gold and green lines illustrate the page life cycles during file upload.

  • When the FileUploadMode property is set to BeforePageLoad (the green line), file upload is performed on the control's Init event, which is called before the Page_Init event. Note that at this time, other controls on the page are not completely initialized, and are not available in file upload events. After file upload is complete, the request execution is aborted and the Unload event is called.
  • When the FileUploadMode property is set to OnPageLoad (the gold line), the file upload is performed on the control's Load event, which is called after the Page_Load event. After file upload is complete, the request execution is aborted and the Unload event is called.

Expanded Creating ASPxUploadControl at Runtime

When ASPxUploadControl is created dynamically at runtime, its events are not initially synchronized with those of other controls on the page. For more information, see the Catch-up Events for Added Controls paragraph in the ASP.NET Page Life Cycle Overview MSDN topic. Therefore, when file upload is performed on the Init event, it can cause code skipping.

Example

In this example, ASPxUploadControl is created in the Page_Load event handler. The control is party initialized before it is added to the page hierarchy. After the control is added, it raises the Init event. Since the FileUploadMode property is set to BeforePageLoad by default, file upload is performed on the Init event. After the upload is performed, the request execution is aborted. Therefore, the next code is not executed on file upload.

To prevent the code from skipping during file upload, set the FileUploadMode property to OnPageLoad. In this case, file upload is performed on the control's Load event, after the Page_Load event handler has been fully processed.

How would you rate this topic?​​​​​​​