ASP .NET Validators broken in FireFox
I'm struggling with ASP .NET Validators JavaScript issue. Following function (part of framework generated code) tries to access validatioGroup attribute value using control.Field syntax. It works fine in IE, however in FF that value is always undefined. Consequently, validation always passes and my validation scenario is broken... Is there a way to get round it?
function IsValidationGroupMatch(control, validationGroup) {
if ((typeof(validationGroup) == "undefined") || (validationGroup == null)) {
return true;
}
var controlGroup开发者_运维百科 = "";
if (typeof(control.validationGroup) == "string") {
controlGroup = control.validationGroup;
}
return (controlGroup == validationGroup);
}
Thanks, Pawel
Here is the culprit:
<xhtmlConformance mode="Strict"/>
I had that line in web.config . Setting to default value, which is Transitional fixed the issue. Here is a background of the topic: Client side validation in FF
If ASP.NET (incorrectly) determines the browser doesn't support validation via client side scripting then the validation will only be performed on the server side.
But server side validation only seems to happen if your event handler includes the Page.IsValid
check at the start of the event handler method.
It's good practice to include this check anyway in case the browser has javascript disabled.
public void MyButton_Click(object sender, EventArgs e)
{
if (!Page.IsValid) return;
... the rest of your event handler ....
}
精彩评论