diff --git a/README.md b/README.md index e9f41144..f0ec1a4e 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ There are a significant number of controls in ASP.NET Web Forms, and we will foc - [CheckBox](docs/EditorControls/CheckBox.md) - [CheckBoxList](docs/EditorControls/CheckBoxList.md) - [DropDownList](docs/EditorControls/DropDownList.md) - - FileUpload + - [FileUpload](docs/EditorControls/FileUpload.md) - [HiddenField](docs/EditorControls/HiddenField.md) - [Image](docs/EditorControls/Image.md) - [ImageButton](docs/EditorControls/ImageButton.md) diff --git a/docs/EditorControls/FileUpload.md b/docs/EditorControls/FileUpload.md new file mode 100644 index 00000000..d87d0ba1 --- /dev/null +++ b/docs/EditorControls/FileUpload.md @@ -0,0 +1,195 @@ +# FileUpload + +The **FileUpload** component allows users to select files from their local file system for upload to the server. It emulates the ASP.NET Web Forms FileUpload control with similar properties and behavior. + +Original Microsoft documentation: https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.fileupload?view=netframework-4.8 + +## Features Supported in Blazor + +- `HasFile` - indicates whether a file has been selected +- `FileName` - gets the name of the selected file +- `FileBytes` - gets the file contents as a byte array +- `FileContent` - gets a Stream to read the file data +- `PostedFile` - gets a wrapper object compatible with HttpPostedFile +- `AllowMultiple` - allows selection of multiple files +- `Accept` - specifies file type restrictions (e.g., "image/*", ".pdf,.doc") +- `MaxFileSize` - sets maximum allowed file size in bytes (default: 500KB) +- `SaveAs(path)` - saves the uploaded file to a specified server path +- `GetMultipleFiles()` - retrieves all selected files when AllowMultiple is true +- `SaveAllFiles(directory)` - saves all selected files to a directory +- `Enabled` - enables or disables the control +- `Visible` - controls visibility +- `ToolTip` - tooltip text on hover +- All style properties (`BackColor`, `ForeColor`, `BorderColor`, `BorderStyle`, `BorderWidth`, `CssClass`, `Width`, `Height`, `Font`) + +### Blazor Notes + +- The control renders as a standard HTML `` element +- File processing must be handled through component properties or methods +- The `OnFileSelected` event fires when files are selected +- Maximum file size should be configured based on your server's capabilities +- For Blazor WebAssembly, file data is read in the browser before being sent to the server + +## Web Forms Features NOT Supported + +- Direct postback behavior - use event handlers instead +- Automatic form submission - implement form handling in Blazor +- Server-side file system access in WebAssembly - must send to API endpoint + +## Web Forms Declarative Syntax + +```html + +``` + +## Blazor Syntax + +```razor + + +