I am using the "PostbackTriggers" property of the Upload control, as described on your web site article "How to Persist Uploaded Files". This works well for the situation where I need a postback on a control, but that control is not a "submit" control. The problem comes when I use one of the "submit" controls (listed in the PostbackTriggers property), but a server side validation error occurs, and the form data (including uploaded files) is NOT saved to the DB. (This is a type of validation that can only be done on the server side.) In that case, the upload control loses the uploaded file information. Thus two questions: 1. Is there a way on the server side to tell the control that an error has occurred, and to continue to persist the uploaded file information? 2. Is there a way for the upload control to ALWAYS persist the uploaded file information until told on the server side that I have extracted the information I need from it?
Hello Steven,
Actually, the Postback triggers can be manipulated in the PageInit event where you can do the server-side validation and decide whether or not to persist the file:
Another thing you might find helpful is the EnableCustomValidation property which when set to true will preserve the files when the Page is invalid. You can see a real example in the following online demo or a simple example in the snippet below:
<telerik:RadAsyncUpload runat="server" EnableCustomValidation="true"></telerik:RadAsyncUpload>
<asp:TextBox runat="server" ID="txt1" />
<asp:RequiredFieldValidator ErrorMessage="Enter text" EnableClientScript="false" ControlToValidate="txt1" runat="server" />
<telerik:RadButton runat="server" ID="RadButton1" Text="Postback" AutoPostBack="true" />
Regards,
Peter Milchev
Progress Telerik