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
   Getting Started
  [Expand]Grid View
  [Expand]Tree List
  [Expand]Card View
  [Expand]Reporting
  [Expand]Chart Control
  [Expand]Pivot Grid
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Scheduler
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Gauges
  [Expand]Vertical Grid
  [Expand]Data Editors
  [Expand]Docking and Popups
  [Collapse]File Management
   [Expand]Product Information
   [Expand]File Manager
   [Collapse]File Upload
     ASPxUploadControl Overview
    [Collapse]Concepts (ASPxUploadControl)
      Upload Modes
      Uploading Large Files
      Multi-File Selection
      Page Life Cycle During File Upload
      Drag and Drop
     [Expand]Validation
      Appearance Customization
    [Expand]Visual Elements
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Controls
  [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]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[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.

Is this topic helpful?​​​​​​​