thanks
38 Answers, 1 is accepted
I am afraid that it is not possible to achieve such aim. My suggestion is to submit the form with the postback trigger after you have done all validations. E.g. first you postback and do all checks and calculations and if everything is fine the postback trigger is enabled and you could submit the page with it.
Regards,
Peter Filipov
the Telerik team

scott
That was exactly what I meant. I am happy to hear that it works for you.
Let me know if you need further assistance.
All the best,
Peter Filipov
the Telerik team

This should be a common issue for most folks, so I hope that your team is able to enhance the control to make the solution easier and more seamless.
scott
We are going to consider your suggestion and eventually log it in our tracking system.
The issue here is that a validation is done when a PostbackTrigger do the postback. This could be avoided by separating the business logic and fire the PostbackTrigger as a last step in the logical chain.
Kind regards,
Peter Filipov
the Telerik team

@Telerik, or @ScottB, can one of you post an example of the code that uses the workaround? I'm not quite following how to seperate the postbacktrigger with the regular submit click.
thanks.
Please review the following demo. Notice how the "Submit your picture information" button is enabled after the comboboxes are selected. Only if the submit button do the postback the picture is processed.
Kind regards,
Peter Filipov
the Telerik team

is there a way on the server side to keep track of the file path of the selected file and then set the selected file back to that filepath after the postback finishes?

I forgot to post my code example...here you go.
ASPX code…
RadAsyncUpload control. . .
<telerik:RadAsyncUpload
ID="Form_Attachments"
runat="server"
TargetFolder="~\App_Data\RadUploadTarget"
TemporaryFolder="~\App_Data\RadUploadTemp"
PostbackTriggers="Form_SubmitButton ">
</telerik:RadAsyncUpload>
Validate button. . .
<asp:Button
ID="Form_SubmitButtonValidate"
runat="server"
CssClass="basicButton"
Text="Submit"
onclick="Form_SubmitButtonValidate_Click" />
Hidden submit button. . . (uses image button with spacer.gif to make it invisible)
<asp:ImageButton
ID="Form_SubmitButton"
runat="server"
ImageUrl="~/Images/spacer.gif"
ToolTip=""
AlternateText=""
onclick="Form_SubmitButton_Click" />
ASPX C# code behind...
protected void Form_SubmitButtonValidate_Click(object sender, System.EventArgs e)
{
// Do server side validation here...
// If server side validation succeeds, then execute javascript to trigger
// event Form_SubmitButton_Click.
string _javascript = "var _button = document.getElementById('" +
this.Form_SubmitButton.ClientID + "'); if (_button != null) {_button.click();}";
if (ScriptManager.GetCurrent(this.Page) != null)
{
// When in AJAX context...
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "submitForm",
_javascript,true);
}
else
{
// When NOT in AJAX context...
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "submitForm",
_javascript, true);
}
}
/// <summary>
/// Postback event to save form data...
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Form_SubmitButton_Click(object sender, ImageClickEventArgs e)
{
// Do server side logic to save validated form data...
}
User clicks Form_SubmitButtonValidate which triggers event Form_SubmitButtonValidate_Click. This issues a server PostBack, but is NOT recognized by the RadAsyncUpload control as a PostbackTrigger, so RadAsyncUpload remains unchanged.
In Form_SubmitButtonValidate_Click event, the form validation logic is performed and if successful, javascript is triggered to click the hidden image button called Form_SubmitButton (see in ASPX code). This causes the server PostBack and is recognized by the RadAsynUpload as a PostbackTrigger.


Regards,
Devinder
You can persist the uploaded files from processing by setting the PostbackTriggers to the appropriate button as it is explain in this documentation article.
If you mean something else by "retaking the file names" please elaborate the scenario a little bit because it is not quite clear.
Plamen
the Telerik team


Basically i want server side validation. If this validation fails, i want the asynupload to retain its file list.
Is there a cleaner way?

In the Form_Submit_Validate_Click handler, the radAsyncUplolad1.UploadedFiles.Count is always zero.
So how can i serverside validate any of the uploaded files before submission?

Here is the scenario that my code resolves:
1. User enters some data on the web page.
2. User uploads (using RadUpload) files.
3. User clicks a Submit button.
4. System performs server side validation of user entered data from step #1.
5. Validation fails for some reason.
6. System displays message.
7. User re-enters problem data on the web page.
8. User clicks Submit again.
9. Server side validation succeeds.
10. User entered data AND uploaded files are processed.

Does anyone know if it's possible to validate the uploaded filed and persist the uploaded files on a failed validation?
I would think this would be a fairly common request.
Maybe one of the telerik staff can chime in here.

I've continued with your solution, but the javascript doesn't seem to trigger the button click. The button is always null. Could this be because i'm using radbuttons instead of regular asp buttons?
Should the validate button be set to AutoPostBack=False?

As to your question regarding Autopostback=False, no. The button click must trigger a Postback.


Hmm... I think there's something else going on here. if i change your code and add an alert i get "object htmlspanelement" back rather than "object htmlinputelement" or the button.
I then changed my form to use a normal asp button and everything works great.
Originally i had modified your javascript to use $find() to get a reference to the radbutton. That function always returned null. I'm still unclear why? Could one of the telerik folks chime in and explain this?
Thanks.
We are going to research this more deeply and will get back to you with more information.
Regards,
Hristo Valyavicharski
Telerik

Another issue i'm running into is i cant' redirect to a success page after a successful submission.
In the Form_SubmitButton_Click handler i do a Response.Redirect() which does nothing. I've also tried Server.Transfer().
Hmmm...


Thanks for your help Scott. I really appreciate it. The telerik guys are looking into the radbutton vs button issue.
we made a detailed research on this issue, but we didn't manage to find another working approach. Andre I suggest you to use Scott's solution. It is working fine. The issue with the buttons is expected. $find can be used only for Ajax controls. If you use non-ajax controls you should use $get. Difference between both is well explain here.
Regards,Hristo Valyavicharski
Telerik

The problem is, how do we perform server-side validation on the uploaded file itself, and it would appear Telerik has no answer for this. From my standpoint, it isn't necessary to get access to the file server-side and validate all its attributes (file size, illegal file types, etc.), because all of this can be handled client-side. However, there is one form of validation that is required server-side.... Required Field Validation. If the AsyncUpload is a required field, then there doesn't appear to be any way to validate it prior to submitting the file. Surely there must be some way to ascertain whether a file has been uploaded server-side without actually submitting the file, seeing as a temporary file does get created. I'm hoping Teleric is working on a way to determine this server-side prior to submitting a file. Perhaps a property like RadUpload.FileIsUploaded (True/False), or something to that affect.
At the moment the only one way to implement a server side validation is to use a Custom Handler and perform the validation in the Process() method and return a custom result on the client. At the moment we are working to improve the server side validation process of the AsyncUpload control.
Regards,
Hristo Valyavicharski
Telerik
DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.



Unfortunately I couldn't replicate the issue at my end. After setting PostbackTriggers for RadAsyncUpload, the uploaded file will save to the TargetFolder only through the postback happened by the PostbackTrigger control. This is the default behavior of the control. If the page reload is happening then the control will lose the selected file but it will not saved into the TargetFolder. Please have a look into the sample code snippet which works fine at my end.
ASPX:
<
telerik:RadAsyncUpload
ID
=
"rasynuploadAllFiles"
runat
=
"server"
TargetFolder
=
"Uploads"
PostbackTriggers
=
"rbtnUpload"
>
</
telerik:RadAsyncUpload
>
<
telerik:RadButton
ID
=
"rbtnUpload"
runat
=
"server"
Text
=
"Upload"
>
</
telerik:RadButton
>
Please elaborate your requirement if it doesn't help.
Thanks,
Shinu.

Try to use server validation:
http://demos.telerik.com/aspnet-ajax/asyncupload/examples/server-side-validation/defaultcs.aspx
Regards,
Hristo Valyavicharski
Telerik

There are no hidden buttons in the pointed demo. A new property was introduced:
<
telerik:RadAsyncUpload
runat
=
"server"
EnableCustomValidation
=
"true"
ID
=
"RadAsyncUpload1"
MultipleFileSelection
=
"Automatic"
Skin
=
"Silk"
OnFileUploaded
=
"RadAsyncUpload1_FileUploaded"
>
</
telerik:RadAsyncUpload
>
Regards,
Hristo Valyavicharski
Telerik

hi,
Can anyone help me..urgently..
i have used RAD upload control for file uploading(.csv) and after uploaded file i push that file into another button and at that time telerik control get hide so please help
Can you elaborate a little bit more? What exactly is the issue? Paste your code here or attach sample.
Thanks.
Regards,
Hristo Valyavicharski
Telerik
