Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > CustomValidator not working in FireFox

Reply
Thread Tools

CustomValidator not working in FireFox

 
 
Glen
Guest
Posts: n/a
 
      06-27-2006
In ASP.NET 2.0, the validators are not working correctly in FireFox
(1.5.0.4).

For example, in the script given to FireFox by WebResource.axd, the function
IsValidationGroupMatch
has this:
if (typeof(control.validationGroup) == "string")

In FireFox, that does not seem to work. The "expando" property is not
recognized. Instead, this would work:
if (typeof(control.attributes["validationgroup"].value) == "string")


Fixing that does not resolve all the issues however, since other functions,
like:
ValidatorValidate
have code like this:
if (typeof(val.evaluationfunction) == "function")

In FireFox, that fails.

Is there any supported fix for this?
Thanks,
Glen


 
Reply With Quote
 
 
 
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      06-28-2006
Hi Glen,

Thank you for your update.

There were some limitation in ASP.NET 1.1 that prevents custom validator
from working correctly. As far as I know, the custom validator should work
in ASP.NET 2.0. Would you please posting some repro code here so that we
can see the problem more clearly?


Regards,
Walter Wang ((E-Mail Removed), remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
 
 
 
Glen
Guest
Posts: n/a
 
      06-28-2006
I'm not sure what I can do beyond what my initial note had...

The way I was able to see details was to use Firefox, with the Javascript
debugger extension (https://addons.mozilla.org/firefox/216/). Build a simple
..NET 2.0 page that has some validation controls on it. Test, and you will
see that validation does not work.

When tracing in the debugger, you can see that the expando properties are
not recognized, though they do exist in the "attributes" collection.

Expando attributes are fine in Firefox, but cannot be accessed as if they
are a part of the DOM as IE allows. Any attribute that is not part of the
DOM is only accessible via obj.getAttribute('x') or
obj.attributes['x'].value.

The ASP.NET 2.0 client script library needs to be updated to avoid the
DOM-like property access to expando attributes. Instead, use getAttribute().

Some links re expandos:
http://msdn.microsoft.com/library/de...es/expando.asp
http://www.xulplanet.com/ndeakin/archive/2004/9/12/
http://www.howtocreate.co.uk/tutoria...ript/dombasics

Also, all HTML attributes are supposed to be caseless, so <span age="23" />
and <span Age="23" /> are identical. However IE 6 treats them as two
different attributes, so be sure that all references are in lowercase!

Re lowercase attributes:
HTML4: "in HTML, element and attribute names are case-insensitive"
(http://www.w3.org/TR/1999/REC-html40...t.html#h-1.2.1)
XHTML: "XHTML documents must use lower case for all HTML element and
attribute names." (http://www.w3.org/TR/xhtml1/#h-4.2)

Simple example:
<html>
<body>
<div id="abc" age="23" Age="56"></div>
<script>
var d = document.getElementById('abc')
alert(d.id) // okay in both
alert(d.age) // 23 in IE, undefined in firefox
alert(d.Age) // 56 in IE, undefined in firefox
alert(d.attributes['age'].value) // 23 in both
alert(d.attributes['Age'].value) // 56 in IE, 23 in Firefox
</script>
</body>
</html>

GLen


"Walter Wang [MSFT]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Glen,
>
> Thank you for your update.
>
> There were some limitation in ASP.NET 1.1 that prevents custom validator
> from working correctly. As far as I know, the custom validator should work
> in ASP.NET 2.0. Would you please posting some repro code here so that we
> can see the problem more clearly?
>
>
> Regards,
> Walter Wang ((E-Mail Removed), remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>



 
Reply With Quote
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      06-29-2006
Hi Glen,

Thank you for your update.

Based on my understanding, the expando property problem should have been
fixed in current version of ASP.NET 2.0. For example, before Beta2, a
RequiredFieldValidator renders following HTML when requested by an uplevel
browser:

<span
controltovalidate="text1"
id="required1"
evaluationfunction="RequiredFieldValidatorEvaluate IsValid"
validationgroup="grp1"
initialvalue=""
style="color:Red;visibility:hidden;">required</span>

The controltovalidate, evaluationfunction, validationgroup and initialvalue
attributes are Expando properties.

During my test, this has been fixed in current version of ASP.NET 2.0 and
will render as:

<span id="required1"
style="color:Red;visibility:hidden;">required</span>

<script type="text/javascript">
<!--
var required1 = document.all ? document.all["required1"] :
document.getElementById("required1");
required1.controltovalidate = "text1";
required1.errormessage = "required";
required1.validationGroup = "grp1";
required1.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
required1.initialvalue = "";
// -->
</script>

As you can see, these attributes such as "validationGroup" are no longer
defined as expando properties.

I've done some test using some standard validators and created a simple
custom validator to test in Firefox and it works correctly.

Since you're encountering some error when using validators in Firefox, I
would suggest following possible causes to track down the problem.

1) ASP.NET 2.0 introduced concept of "ValidationGroup" which can be used in
3 places:

* BaseValidator: Use ValidationGroup property to specify which
validation group this validation control belongs.

* ValidationSummary: Use ValidationGroup property to specify the name of
the validation group for which the ValidationSummary control will summarize
error messages.

* Controls that will cause postback and have set
"CausesValidation=true", these controls each have a ValidationGroup
property that, when set, validates only the validation controls within the
specified group when the control triggers a post back to the server.

* System.Web.UI.WebControls.BulletedList
* System.Web.UI.WebControls.Button
* System.Web.UI.WebControls.CheckBox
* System.Web.UI.WebControls.CheckBoxList
* System.Web.UI.WebControls.DropDownList
* System.Web.UI.HtmlControls.HtmlButton
* System.Web.UI.HtmlControls.HtmlInputButton
* System.Web.UI.HtmlControls.HtmlInputImage
* System.Web.UI.WebControls.ImageButton
* System.Web.UI.WebControls.LinkButton
* System.Web.UI.WebControls.ListBox
* System.Web.UI.WebControls.RadioButtonList
* System.Web.UI.WebControls.TextBox

As you can see, if you have set ValidationGroup for your validators,
only controls with the same ValidationGroup value will trigger the
validation of these validators.

2) ASP.NET 2.0 uses user-agent of browser to determine the browser is
uplevel or downlevel, you can find browser definition at
%windir%\Microsoft.NET\Framework\<version>\Config\ Browsers. Please verify
the user-agent that your Firefox browser sending is correct. It should work
for a default installation of Firefox. During my test, the javascript files
generated by WebResource.axd are the same from IE or Firefox, you can
verify this by manually copy the javascript src url to browser address bar
and save it locally. If they're different, which means probably the browser
is not recognized correctly.

3) Is it possible that you're using some Firefox extension that prevents
the javascript from rendering correctly?

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang ((E-Mail Removed), remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CustomValidator not working in FormView J. Cairn ASP .Net Web Controls 1 09-20-2007 04:51 PM
CustomValidator on CheckBox not working theresa ASP .Net 2 09-12-2007 05:02 PM
CustomValidator Doesn't Run on FireFox Steve Murphy ASP .Net 7 08-03-2005 05:01 PM
CustomValidator not working tshad ASP .Net 4 11-12-2004 05:04 PM
CustomValidator does not fire =?Utf-8?B?Vmk=?= ASP .Net 1 11-08-2004 01:12 AM



Advertisments