CalendarXP.net Support Forum Index CalendarXP.net Support
Most forums here are private and invisible to public.
 
 FAQFAQ   SearchSearch   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Calendar Control and .Net Validators.

 
Post new topic   Reply to topic    CalendarXP.net Support Forum Index -> PopCalendarXP Related
View previous topic :: View next topic  
Author Message
PRANA



Joined: 10 Apr 2006
Posts: 6

PostPosted: Tue Apr 11, 2006 9:02 pm    Post subject: Calendar Control and .Net Validators. Reply with quote

Has anyone tried to use date picker in a .Net 1.1 application with a text box that also has required field validator? We are getting an error in ValidatorOnChange function of WebUIValidation.js file.

Thanks in advance for any help/suggestions.
Back to top
View user's profile Send private message
calendarxp
Site Admin


Joined: 30 Jan 2005
Posts: 409

PostPosted: Tue Apr 11, 2006 10:34 pm    Post subject: Reply with quote

It's because the calendar will trigger the onchange event using a javascript call while the client-side validator scripts assume the onchange event can only be triggered via a real user interaction - the major difference is that the event.srcElement of a script-triggered onchange will not be the desired input field.

To work around, we just need to patch the WebUIValidation.js file.

1st, find ValidatorOnChange function and replace it with following one:
Code:
function ValidatorOnChange(el) {
    var vals = el.Validators;
    var i;
    for (i = 0; i < vals.length; i++) {
        ValidatorValidate(vals[i]);
    }
    ValidatorUpdateIsValid();   
}

2nd, find the following string:
Code:
var func = new Function("ValidatorOnChange(); " + ev);
and replace it with
Code:
var func = new Function("ValidatorOnChange(this); " + ev);

Now, the error should be gone.

_________________
Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved.
Back to top
View user's profile Send private message
PRANA



Joined: 10 Apr 2006
Posts: 6

PostPosted: Tue Apr 11, 2006 11:00 pm    Post subject: Reply with quote

Thanks for the solution. It wroks and error is gone.

But we can not implement this solution since WebUIValidation.js file is shared by a number of applications on server. Changing this file means testing all the existing applications to make saure none of the validations are failing on IE and Netscape/Firefox.

Is there any solution that would require change(s) only in the files that render Calendar control, ex. ipopeng.htm?

Thanks!
Back to top
View user's profile Send private message
calendarxp
Site Admin


Joined: 30 Jan 2005
Posts: 409

PostPosted: Wed Apr 12, 2006 12:18 am    Post subject: Reply with quote

1st, this solution (patch) should work across browsers and shouldn't affect any existing application on your site. The original code in WebUIValidation.js is the one to be blamed, because it took a short-cut by using event.srcElement instead of passing in the element directly.

Of course, I fully understood your concern - so the next solution we could use is to disable one of the feature in PopCalendarXP so that it won't trigger the onchange event when a date is selected.

To disable this feature, simply make the following line the 1st line of the fAfterSelected() plugin function:
Code:
__isDateChange=false;

This way the calendar will NOT fire the onchange event and therefore won't trigger the Validator scripts.

The downside is, obviously, that you lose the validation provided by ASP.NET if the date is picked via calendar. However, it may not be a big deal since the calendar always format the date in a desired way.

You can still keep the auto-post-back behavior of your page by adding the following line to the last line of fAfterSelected() plugin:
Code:
gdCtrl.form.submit();


Finally, please note that this issue is a common one to any date picker product, not just PopCalendarXP. It's really a bug, more or less, in the WebUIValidation.js of ASP.NET.

_________________
Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved.
Back to top
View user's profile Send private message
chris_motch



Joined: 14 Mar 2006
Posts: 3

PostPosted: Wed Apr 12, 2006 12:59 pm    Post subject: Reply with quote

Just in case anyone else is looking at this. I'm using ASP.NET 2.0, and the solution above with the __isDateChange=false; is probably the best bet, reason being is with 2.0 there is no JS file so to speak, its a .axd file that I believe .NET generates on the fly etc.
Back to top
View user's profile Send private message
PRANA



Joined: 10 Apr 2006
Posts: 6

PostPosted: Wed Apr 12, 2006 2:14 pm    Post subject: Reply with quote

Thanks for the second solution. It works beautifully.

Chris,

Thanks for confirming the solution!

Very Happy
Back to top
View user's profile Send private message
calendarxp
Site Admin


Joined: 30 Jan 2005
Posts: 409

PostPosted: Thu Apr 13, 2006 3:29 am    Post subject: Reply with quote

After further investigation on the behavior of ASP.NET, both 1.x and 2.0, we decided to remove the automatic triggering of onchange event when a date is picked.

Therefore, as from version 9.7.293 the issue should be gone no matter __isDateChange is set or not, because the calendar engine will not trigger the onchange event of the input field any more.

Of course, you may still enable it by yourself by adding the following code to the fAfterSelected plugin function:
Code:
if (gdCtrl.onchange) gdCtrl.onchange();

But you just have to remember to patch the client-side scripts generated by ASP.NET in order to avoid conflicts, as discussed before.

From our point of view, we really wish ASP.NET team could choose a right way to implement the Validator scripts so that the validation can be triggered via 3rd party scripts. However, it might just stay as a good wish. Sad

_________________
Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    CalendarXP.net Support Forum Index -> PopCalendarXP Related All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Copyright 2003- Idemfactor Solutions, Inc. All rights reserved.
Powered by phpBB © 2001, 2005 phpBB Group