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

[RePost] Client Validation in LoadFromContent

8 Answers 131 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Joan Vilariño
Top achievements
Rank 2
Joan Vilariño asked on 21 May 2010, 10:33 AM
Hello... you replied me that you were using MS Ajax in loadfromcontent, and that's why DataAnnotations validations didn't work with TabStrip.

Have you made any update on this? I really need to do client validations on "live" loaded content, as my form is very large and I don't want to preload ALL the form for tabs that won't be used.

Would it be too hard for you to changed loadfromcontent to use jQuery instead msAjax ?

Thanks

8 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 21 May 2010, 11:18 AM
Hello Joan VilariƱo,

We are actually using jQuery to make an Ajax request to the server. The problem is caused by the inability of the client validation to update the MVC client validation metadata on the client. There is a workaround for this issue. For your convenience I have attached simple test project, which implements the aforementioned workaround.

Greetings,
Georgi Krustev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Joan Vilariño
Top achievements
Rank 2
answered on 21 May 2010, 02:07 PM
I've checked your application...

The workaround you mention is to include 3 script files:

<script type="text/javascript" src="<% = Url.Content("~/Scripts/MicrosoftAjax.js") %>"></script
<script type="text/javascript" src="<% = Url.Content("~/Scripts/MicrosoftMvcValidation.js") %>"></script
<script type="text/javascript" src="<% = Url.Content("~/Scripts/RemoteValidator.js") %>"></script
 

and then add :

<script language="javascript"
    Sys.Mvc.FormContext._Application_Load(); 
</script> 

at the bottom of the partial view to load... right?

When I do this I get an error

Error en tiempo de ejecuciĆ³n de Microsoft JScript: 'null' es nulo o no es un objeto (in english: runtime error, 'null' is null or not an object') at file MicrosoftMvcValidation.js at line 14 ... the code reads (formElement['__MVC_FormValidation'] = this;) << formElement is null....

Any suggestion??


0
Joan Vilariño
Top achievements
Rank 2
answered on 21 May 2010, 02:13 PM
Forgot to mention... I found a difference in your application. Your application has the form inside the partial view, so it's inside the tabthat gets loaded, while in my application, the TabStrip object itself is enclosed inside one single form that spans all tabs... like this:

 
<form> 
<% Html.Telerik().Tabstrip().Items(it=>it.Add().bleh bleh bleh; it.Add().bleh another one... .Render(); %> 
</form> 

Can this be the reason for the javascript error ?

Thanks!
0
Bill
Top achievements
Rank 1
answered on 30 Aug 2010, 10:07 AM
Hi,
Did you ever get this resolved?

I'm getting a very similar issue trying to get the data grid to work using AJAX binding.
The error occurs for me in MicrosoftMvcValidation.js on the underlined line of code (5).
     this._errors = [];
    this.fields = new Array(0);
    this._formElement = formElement;
    this._validationSummaryElement = validationSummaryElement;
    formElement[Sys.Mvc.FormContext._formValidationTag] = this;
    if (validationSummaryElement) {
        var ulElements = validationSummaryElement.getElementsByTagName('ul');
        if (ulElements.length > 0) {
            this._validationSummaryULElement = ulElements[0];


0
Joan Vilariño
Top achievements
Rank 2
answered on 15 Sep 2010, 08:20 AM
Hi Bill... sorry for the delay I wasn't tracking this post anymore.

I didn't have time to invest finding a solution for this, so I started a new approach and I'm validating my forms serverside with an ajax call.. If you want some help on that just make me know and I can toss a little code snippet into this thread.

Cheers
0
Kevin
Top achievements
Rank 1
answered on 29 Jul 2011, 07:48 PM
Joan, 
Please provide the code snippet and any updates on this validation problem.

Thanks, 
Steve
0
Henry
Top achievements
Rank 1
answered on 25 Aug 2011, 09:29 AM
Hi Georgi Krustev,

Your post is very useful, I just add below code in the partial view, it works fine. Thank you.

<script type="text/javascript">
    Sys.Mvc.FormContext._Application_Load();
</script>
 
Regards,
Henry
0
Simar
Top achievements
Rank 1
answered on 01 May 2013, 05:51 PM
Adding in the Ready function did the job    
$(document).ready(function () {
            if (jQuery.validator !== undefined) {
                jQuery.validator.unobtrusive.parse('form');
            }
        });
Tags
TabStrip
Asked by
Joan Vilariño
Top achievements
Rank 2
Answers by
Georgi Krustev
Telerik team
Joan Vilariño
Top achievements
Rank 2
Bill
Top achievements
Rank 1
Kevin
Top achievements
Rank 1
Henry
Top achievements
Rank 1
Simar
Top achievements
Rank 1
Share this question
or