Class AjaxAttachments
Attachment-style upload control for forms that need a compact file list with remove support.
Implements
Inherited Members
Namespace: AjaxUploader.Controls
Assembly: AjaxUploader.dll
Syntax
public class AjaxAttachments : WebControl, IComponent, IDisposable, IParserAccessor, IUrlResolutionService, IDataBindingsAccessor, IControlBuilderAccessor, IControlDesignerAccessor, IExpressionsAccessor, IAttributeAccessor, IPostBackDataHandler
Constructors
AjaxAttachments()
Initializes a new instance of the AjaxAttachments control.
Declaration
public AjaxAttachments()
Properties
AutoPostBack
Gets or sets whether the control posts back automatically when the upload batch finishes, so FileUploaded fires without a submit button. Defaults to off, matching AjaxFileUpload: with it off the events run on the page's next postback instead.
Declaration
public bool AutoPostBack { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
ButtonText
Gets or sets the button text used to open the file picker.
Declaration
public string ButtonText { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Extensions
Gets or sets the allowed file extensions as a comma-separated list.
Declaration
public string Extensions { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Items
Gets the files uploaded in the current postback, with data access attached - enumerate from any postback handler to read, copy or move each file.
Declaration
[Browsable(false)]
public IList<UploadedFile> Items { get; }
Property Value
| Type | Description |
|---|---|
| IList<UploadedFile> |
Remarks
The v4 Items pattern on the modern control. Guids whose stored file is
gone (already moved, or swept) are skipped rather than returned as empty
entries, matching the event path's stale-guid guard.
MaxFiles
Gets or sets the maximum number of files that can be attached through the control.
Declaration
public int MaxFiles { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
MaxSize
Gets or sets the maximum allowed file size.
Declaration
public string MaxSize { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
OnClientChange
Gets or sets the JavaScript callback invoked when the attachment list changes. The callback receives the client attachment state after uploads, removals, or other list updates.
Declaration
public string OnClientChange { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Removable
Gets or sets whether attached files can be removed from the client list.
Declaration
public bool Removable { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
ShowSize
Gets or sets whether file sizes are shown in the attachment list.
Declaration
public bool ShowSize { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
UploadUrl
Gets or sets a custom upload endpoint for attachment uploads. When left empty, the standard AjaxUploader handler upload endpoint is used.
Declaration
public string UploadUrl { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
UploadedFileGuids
Gets the uploaded file GUIDs restored from postback data. Use this list during page processing to associate attached files with the surrounding form data.
Declaration
[Browsable(false)]
public List<Guid> UploadedFileGuids { get; }
Property Value
| Type | Description |
|---|---|
| List<Guid> |
Methods
LoadPostData(string, NameValueCollection)
Loads the hidden attachment GUID list from postback data. The values are written by the client attachment widget into the hidden field rendered by the control.
Declaration
public virtual bool LoadPostData(string postDataKey, NameValueCollection postCollection)
Parameters
| Type | Name | Description |
|---|---|---|
| string | postDataKey | |
| NameValueCollection | postCollection |
Returns
| Type | Description |
|---|---|
| bool |
OnPreRender(EventArgs)
Raises the PreRender event.
Declaration
protected override void OnPreRender(EventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| EventArgs | e | An EventArgs object that contains the event data. |
Overrides
RaisePostDataChangedEvent()
Raises post-data changed notifications for the attachment control. This implementation is intentionally empty; inspect UploadedFileGuids during page processing.
Declaration
public virtual void RaisePostDataChangedEvent()
Render(HtmlTextWriter)
Renders the control to the specified HTML writer.
Declaration
protected override void Render(HtmlTextWriter writer)
Parameters
| Type | Name | Description |
|---|---|---|
| HtmlTextWriter | writer | The HtmlTextWriter object that receives the control content. |
Overrides
Events
FileUploaded
Occurs once per uploaded file after the upload postback. Use the args'
OpenStream() / CopyTo() / MoveTo() to consume the data.
Declaration
public event EventHandler<FileUploadedEventArgs> FileUploaded
Event Type
| Type | Description |
|---|---|
| EventHandler<FileUploadedEventArgs> |
FileValidating
Occurs before an uploaded file is accepted; set Cancel to skip it.
Declaration
public event EventHandler<FileValidatingEventArgs> FileValidating
Event Type
| Type | Description |
|---|---|
| EventHandler<FileValidatingEventArgs> |
UploadCompleted
Occurs after every file in the postback has been processed.
Declaration
public event EventHandler UploadCompleted
Event Type
| Type | Description |
|---|---|
| EventHandler |