This is a migrated thread and some comments may be shown as answers.

Retain uploaded files for display after postback / validation problems

8 Answers 1202 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Emanuele
Top achievements
Rank 1
Veteran
Emanuele asked on 11 Jun 2019, 10:12 AM

Hi, i've prepared a form using Rad controls and i need to use 3 controls to Upload files. I had some first problem to validate these controls, solved using hidden fields that I value when a file is uploaded.

So when I press the Submit button (RadButton) the page is actually validated, but if there are problems on some other fields than RadAsyncUpload, the result is that the upload control loses the correct information on display.

I'm using Ajax, Telerik UI R2 2019, the jquery version i see is v1.12.4, Page_ValidationVer = "125";

I've read many discussions, but there's something wrong in my case.

https://docs.telerik.com/devtools/aspnet-ajax/controls/button/how-to/radbutton-validation-and-client-side-event-handlers

 

I tried to intercept the validation in order to maybe implement something like this

https://www.telerik.com/forums/retain-uploaded-files-for-display-after-postback

but I can't, because if I try to call the function  Page_ClientValidate it always returns TRUE.

function Page_ClientValidate(validationGroup) {
    Page_InvalidControlToBeFocused = null;
    if (typeof(Page_Validators) == "undefined") {
        return true;
    }
    var i;
    for (i = 0; i < Page_Validators.length; i++) {
        ValidatorValidate(Page_Validators[i], validationGroup, null);
    }
    ValidatorUpdateIsValid();
    ValidationSummaryOnSubmit(validationGroup);
    Page_BlockSubmit = !Page_IsValid;
    return Page_IsValid;
}

 

Trying in debug i see that Page_Validators = undefined so the function exit with 'true' 

The form submit correctly and server-side i see Page.IsValid property values but I need to perform the submit only where all fields are compiled or the asyncupload controls mantains their state after validation.

 

Could there be confusion between client and server validation?

Do you have any ideas? Thanks

8 Answers, 1 is accepted

Sort by
0
Emanuele
Top achievements
Rank 1
Veteran
answered on 11 Jun 2019, 10:31 AM

Update: if i insert this line in web.config

<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />

 

validations seems to be performed on the clientside, (and the problems about upload controls is solved) except the radiobuttonlists, them are validated server-side generating the problem again

<telerik:RadRadioButtonList ID="rblSex" runat="server" AutoPostBack="False">
    <Items>
        <telerik:ButtonListItem Text="M" Value="M" />
        <telerik:ButtonListItem Text="F" Value="F" />
    </Items>
</telerik:RadRadioButtonList>
<asp:RequiredFieldValidator ID="rfv_sex" runat="server" ErrorMessage="*" ControlToValidate="rblSex" Display="Dynamic" ValidationGroup="std"></asp:RequiredFieldValidator>
0
Emanuele
Top achievements
Rank 1
Veteran
answered on 11 Jun 2019, 10:44 AM

This article talks about jQuery troubleshooting, but i'm not sure of my environment...

https://docs.telerik.com/devtools/aspnet-ajax/general-information/troubleshooting/jquery-troubleshooting#how-to-use-unobtrusive-validation-in-net-45-telerik-web-site--telerik-web-application

i think I've created a Telerik Web Application but how can I verify this?

Also my RadScriptManager is void, only declared in the MasterPage.Master

<telerik:RadScriptManager runat="server" ID="rsmUno"></telerik:RadScriptManager>
0
Accepted
Peter Milchev
Telerik team
answered on 14 Jun 2019, 10:46 AM
Hello Emanuele,

The validation on the client for the RadioButtonList without a postback can be achieved only with CustomValidators: https://docs.telerik.com/devtools/aspnet-ajax/controls/radiobuttonlist/functionality/aspnet-validators-support#validation-on-the-client.

The <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" /> key is needed for client-validation for projects with .NET framework version 4.5 and higher: http://stackoverflow.com/questions/16660900/webforms-unobtrusivevalidationmode-requires-a-scriptresourcemapping-for-jquery.

Here you can find information about the difference between the WebSite and WebApplication: https://stackoverflow.com/questions/398037/asp-net-web-site-or-asp-net-web-application. An easy way is to check the project icon as it is different for the web site and application.

Another thing is that the Web Application has CodeBehind property and aspx.designer.cs file for the web form while the Web site has CodeFile property and no designer files.

Regarding the persistence of the uploaded file across postbacks, you can check the following articles:

Regards,
Peter Milchev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Emanuele
Top achievements
Rank 1
Veteran
answered on 14 Jun 2019, 12:53 PM

Hi,

because my project make a single .dll and files has .aspx.designer.cs i understand that i'm using a web application.

Yesterday i've replaced the required validators with custom validators for radio button controls, and the client-side validation has worked.

this shuffled the cards and the problem about the persistence of the async upload state disappeared :-)

So right now the page is working properly.

Also my void RadScriptManager is this correct?

0
Peter Milchev
Telerik team
answered on 14 Jun 2019, 01:02 PM
Hello Emanuele,

It is good to hear that everything is working now. 

Regarding the RadScriptManager, the declaration as it is now is entirely functioning because all the necessary properties have already defined default values. 

Regards,
Peter Milchev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Emanuele
Top achievements
Rank 1
Veteran
answered on 14 Jun 2019, 01:18 PM
0
Peter Milchev
Telerik team
answered on 14 Jun 2019, 01:24 PM
Yes, you can skip adding the script settings explicitly. If you are using .NET 4.5+ you should have the UnobtrusiveValidationMode setting in the web.config and the client-side validation should work properly.

Regards,
Peter Milchev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Cheah
Top achievements
Rank 1
Veteran
answered on 27 May 2020, 01:44 PM

Sorry Still not understand,

Can give more simple demo?

Thank you.

Tags
AsyncUpload
Asked by
Emanuele
Top achievements
Rank 1
Veteran
Answers by
Emanuele
Top achievements
Rank 1
Veteran
Peter Milchev
Telerik team
Cheah
Top achievements
Rank 1
Veteran
Share this question
or