Home All Groups Group Topic Archive Search About
Author
19 Jul 2006 12:36 PM
Paolo Benetti
Dear all,

I'm trying to add a CustomValidator that must validate a TextBox, ensuring
that the number inserted be in a range of long.
I cannot use RangeValidator because long is not a supported type, and in
addition I wanted to learn to develop a Custom Validator control.

Everything worked fine until I tryied to add 2 different LongRangeValidator
controls on the same page, with 2 different ranges. The problem is that my
ClientValidationFunction is built at runtime with the range limits stamped
in it, that results in the following code rendered:

function ClientLongRangeValidation(source, arguments) {
arguments.IsValid = false;
if (!isNaN(arguments.Value)) {
var val = arguments.Value
  if (arguments.Value >= -9223372036854775808 && arguments.Value <=
9223372036854775807)
   arguments.IsValid = true;
}
}

I see that the normal RangeValidator control adds some interesting rows at
the bottom of the page:
var gnIB1_ctl02 = document.all ? document.all["gnIB1_ctl02"] :
document.getElementById("gnIB1_ctl02");
gnIB1_ctl02.controltovalidate = "gnIB1_gnTxt1";
gnIB1_ctl02.type = "Integer";
gnIB1_ctl02.evaluationfunction = "RangeValidatorEvaluateIsValid";
gnIB1_ctl02.maximumvalue = "2147483647";
gnIB1_ctl02.minimumvalue = "0";

While CustomValidator just adds the following:
var gnIB2_ctl02 = document.all ? document.all["gnIB2_ctl02"] :
document.getElementById("gnIB2_ctl02");
gnIB2_ctl02.controltovalidate = "gnIB2_gnTxt2";
gnIB2_ctl02.errormessage = "Invalid. Min:-9223372036854775808, max:
9223372036854775807";
gnIB2_ctl02.evaluationfunction = "CustomValidatorEvaluateIsValid";
gnIB2_ctl02.clientvalidationfunction = "ClientLongRangeValidation";

It's seems that if I could add a minimumvalue and a maximumvalue fields for
each control, I could write a different client function that would work with
as many controls I'd like.

But how can I add "javascript fields"?
I see that CustomValidator inherits RegisterValidatorCommonScript and
RegisterValidatorDeclaration, but I don't think they're the right methods.

Any help would be appreciated, Thanks.
Paolo Benetti.

Author
19 Jul 2006 1:12 PM
Alessandro Zifiglio
hi Paolo, you can register you two propertis as expando attributes. The
method you are looking for is RegisterExpandoAttribute.

http://msdn2.microsoft.com/en-us/library/ms153123.aspx

Regards,
Alessandro Zifiglio
http://www.AsyncUI.net


Show quoteHide quote
"Paolo Benetti" <pla***@tiscali.it> ha scritto nel messaggio
news:OZvYL9yqGHA.148@TK2MSFTNGP04.phx.gbl...
> Dear all,
>
> I'm trying to add a CustomValidator that must validate a TextBox, ensuring
> that the number inserted be in a range of long.
> I cannot use RangeValidator because long is not a supported type, and in
> addition I wanted to learn to develop a Custom Validator control.
>
> Everything worked fine until I tryied to add 2 different
> LongRangeValidator
> controls on the same page, with 2 different ranges. The problem is that my
> ClientValidationFunction is built at runtime with the range limits stamped
> in it, that results in the following code rendered:
>
> function ClientLongRangeValidation(source, arguments) {
> arguments.IsValid = false;
> if (!isNaN(arguments.Value)) {
> var val = arguments.Value
>  if (arguments.Value >= -9223372036854775808 && arguments.Value <=
> 9223372036854775807)
>   arguments.IsValid = true;
> }
> }
>
> I see that the normal RangeValidator control adds some interesting rows at
> the bottom of the page:
> var gnIB1_ctl02 = document.all ? document.all["gnIB1_ctl02"] :
> document.getElementById("gnIB1_ctl02");
> gnIB1_ctl02.controltovalidate = "gnIB1_gnTxt1";
> gnIB1_ctl02.type = "Integer";
> gnIB1_ctl02.evaluationfunction = "RangeValidatorEvaluateIsValid";
> gnIB1_ctl02.maximumvalue = "2147483647";
> gnIB1_ctl02.minimumvalue = "0";
>
> While CustomValidator just adds the following:
> var gnIB2_ctl02 = document.all ? document.all["gnIB2_ctl02"] :
> document.getElementById("gnIB2_ctl02");
> gnIB2_ctl02.controltovalidate = "gnIB2_gnTxt2";
> gnIB2_ctl02.errormessage = "Invalid. Min:-9223372036854775808, max:
> 9223372036854775807";
> gnIB2_ctl02.evaluationfunction = "CustomValidatorEvaluateIsValid";
> gnIB2_ctl02.clientvalidationfunction = "ClientLongRangeValidation";
>
> It's seems that if I could add a minimumvalue and a maximumvalue fields
> for
> each control, I could write a different client function that would work
> with
> as many controls I'd like.
>
> But how can I add "javascript fields"?
> I see that CustomValidator inherits RegisterValidatorCommonScript and
> RegisterValidatorDeclaration, but I don't think they're the right methods.
>
> Any help would be appreciated, Thanks.
> Paolo Benetti.
>
>
>
Author
19 Jul 2006 1:48 PM
Paolo
Hi Alessandro,

you saved me from insanity.
It works perfectly now.

Many thanks,
Paolo.


Show quoteHide quote
"Alessandro Zifiglio" <AlessandroZifiglio @ -h-o-t-m-a-i-l-c-o-m> wrote in
message news:%23RM69TzqGHA.2440@TK2MSFTNGP03.phx.gbl...
> hi Paolo, you can register you two propertis as expando attributes. The
> method you are looking for is RegisterExpandoAttribute.
>
> http://msdn2.microsoft.com/en-us/library/ms153123.aspx
>
> Regards,
> Alessandro Zifiglio
> http://www.AsyncUI.net
>
>
> "Paolo Benetti" <pla***@tiscali.it> ha scritto nel messaggio
> news:OZvYL9yqGHA.148@TK2MSFTNGP04.phx.gbl...
>> Dear all,
>>
>> I'm trying to add a CustomValidator that must validate a TextBox,
>> ensuring
>> that the number inserted be in a range of long.
>> I cannot use RangeValidator because long is not a supported type, and in
>> addition I wanted to learn to develop a Custom Validator control.
>>
>> Everything worked fine until I tryied to add 2 different
>> LongRangeValidator
>> controls on the same page, with 2 different ranges. The problem is that
>> my
>> ClientValidationFunction is built at runtime with the range limits
>> stamped
>> in it, that results in the following code rendered:
>>
>> function ClientLongRangeValidation(source, arguments) {
>> arguments.IsValid = false;
>> if (!isNaN(arguments.Value)) {
>> var val = arguments.Value
>>  if (arguments.Value >= -9223372036854775808 && arguments.Value <=
>> 9223372036854775807)
>>   arguments.IsValid = true;
>> }
>> }
>>
>> I see that the normal RangeValidator control adds some interesting rows
>> at
>> the bottom of the page:
>> var gnIB1_ctl02 = document.all ? document.all["gnIB1_ctl02"] :
>> document.getElementById("gnIB1_ctl02");
>> gnIB1_ctl02.controltovalidate = "gnIB1_gnTxt1";
>> gnIB1_ctl02.type = "Integer";
>> gnIB1_ctl02.evaluationfunction = "RangeValidatorEvaluateIsValid";
>> gnIB1_ctl02.maximumvalue = "2147483647";
>> gnIB1_ctl02.minimumvalue = "0";
>>
>> While CustomValidator just adds the following:
>> var gnIB2_ctl02 = document.all ? document.all["gnIB2_ctl02"] :
>> document.getElementById("gnIB2_ctl02");
>> gnIB2_ctl02.controltovalidate = "gnIB2_gnTxt2";
>> gnIB2_ctl02.errormessage = "Invalid. Min:-9223372036854775808, max:
>> 9223372036854775807";
>> gnIB2_ctl02.evaluationfunction = "CustomValidatorEvaluateIsValid";
>> gnIB2_ctl02.clientvalidationfunction = "ClientLongRangeValidation";
>>
>> It's seems that if I could add a minimumvalue and a maximumvalue fields
>> for
>> each control, I could write a different client function that would work
>> with
>> as many controls I'd like.
>>
>> But how can I add "javascript fields"?
>> I see that CustomValidator inherits RegisterValidatorCommonScript and
>> RegisterValidatorDeclaration, but I don't think they're the right
>> methods.
>>
>> Any help would be appreciated, Thanks.
>> Paolo Benetti.
>>
>>
>>
>
>
Author
19 Jul 2006 1:58 PM
Alessandro Zifiglio
your more than welcome, Paolo.
Have a good day,
Alessandro Zifiglio
http://www.AsyncUI.net

Show quoteHide quote
"Paolo" <paolo_bene***@hotmail.com> ha scritto nel messaggio
news:u2JnzlzqGHA.4508@TK2MSFTNGP04.phx.gbl...
> Hi Alessandro,
>
> you saved me from insanity.
> It works perfectly now.
>
> Many thanks,
> Paolo.
>
>
> "Alessandro Zifiglio" <AlessandroZifiglio @ -h-o-t-m-a-i-l-c-o-m> wrote in
> message news:%23RM69TzqGHA.2440@TK2MSFTNGP03.phx.gbl...
>> hi Paolo, you can register you two propertis as expando attributes. The
>> method you are looking for is RegisterExpandoAttribute.
>>
>> http://msdn2.microsoft.com/en-us/library/ms153123.aspx
>>
>> Regards,
>> Alessandro Zifiglio
>> http://www.AsyncUI.net
>>
>>
>> "Paolo Benetti" <pla***@tiscali.it> ha scritto nel messaggio
>> news:OZvYL9yqGHA.148@TK2MSFTNGP04.phx.gbl...
>>> Dear all,
>>>
>>> I'm trying to add a CustomValidator that must validate a TextBox,
>>> ensuring
>>> that the number inserted be in a range of long.
>>> I cannot use RangeValidator because long is not a supported type, and in
>>> addition I wanted to learn to develop a Custom Validator control.
>>>
>>> Everything worked fine until I tryied to add 2 different
>>> LongRangeValidator
>>> controls on the same page, with 2 different ranges. The problem is that
>>> my
>>> ClientValidationFunction is built at runtime with the range limits
>>> stamped
>>> in it, that results in the following code rendered:
>>>
>>> function ClientLongRangeValidation(source, arguments) {
>>> arguments.IsValid = false;
>>> if (!isNaN(arguments.Value)) {
>>> var val = arguments.Value
>>>  if (arguments.Value >= -9223372036854775808 && arguments.Value <=
>>> 9223372036854775807)
>>>   arguments.IsValid = true;
>>> }
>>> }
>>>
>>> I see that the normal RangeValidator control adds some interesting rows
>>> at
>>> the bottom of the page:
>>> var gnIB1_ctl02 = document.all ? document.all["gnIB1_ctl02"] :
>>> document.getElementById("gnIB1_ctl02");
>>> gnIB1_ctl02.controltovalidate = "gnIB1_gnTxt1";
>>> gnIB1_ctl02.type = "Integer";
>>> gnIB1_ctl02.evaluationfunction = "RangeValidatorEvaluateIsValid";
>>> gnIB1_ctl02.maximumvalue = "2147483647";
>>> gnIB1_ctl02.minimumvalue = "0";
>>>
>>> While CustomValidator just adds the following:
>>> var gnIB2_ctl02 = document.all ? document.all["gnIB2_ctl02"] :
>>> document.getElementById("gnIB2_ctl02");
>>> gnIB2_ctl02.controltovalidate = "gnIB2_gnTxt2";
>>> gnIB2_ctl02.errormessage = "Invalid. Min:-9223372036854775808, max:
>>> 9223372036854775807";
>>> gnIB2_ctl02.evaluationfunction = "CustomValidatorEvaluateIsValid";
>>> gnIB2_ctl02.clientvalidationfunction = "ClientLongRangeValidation";
>>>
>>> It's seems that if I could add a minimumvalue and a maximumvalue fields
>>> for
>>> each control, I could write a different client function that would work
>>> with
>>> as many controls I'd like.
>>>
>>> But how can I add "javascript fields"?
>>> I see that CustomValidator inherits RegisterValidatorCommonScript and
>>> RegisterValidatorDeclaration, but I don't think they're the right
>>> methods.
>>>
>>> Any help would be appreciated, Thanks.
>>> Paolo Benetti.
>>>
>>>
>>>
>>
>>
>
>