Mandatory field validator + AsyncFileUpload

I am trying to apply the required mandatory ASP.Net default field validator for the AsyncFileUpload control (from the AJAX Control Toolkit).


Scenario

I created a web user control. Lets call it wucFileUpload.

wucFileUpload has an AJAX update panel that wraps the required field analyzer and AsyncFileUpload. (I have to use the AJAX update panel for some reason).

wucFileUpload will be used on many pages, and in some of them this control will be generated automatically, so I don’t know how many of them I will have on the page.

wucFileUpload has the Required property. If Required is true, it will enable the required field validator to check if AsyncFileUpload has been populated at least once.


My attempt

I found https://stackoverflow.com/a/3129609/ and it tried to apply it. However, my case is slightly different from the one presented on this issue.


My thoughts

I really liked the idea of ​​having a hidden text box or HiddenField. Since one AsyncFileUpload can load N number of files.

The text field may get some value the first time OnClientUploadComplete starts ... so I know that the user has uploaded at least one image.

, . , .


, .:)

+3

Source: https://habr.com/ru/post/1787784/


All Articles