2

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

8
  • what version of .net? are you using ajax extensions? Commented Oct 4, 2010 at 14:45
  • Framework version in IIS is set to 2. Do I use ajax extension? Hm, how to check it? Commented Oct 4, 2010 at 16:37
  • IIS will show framework 2.0 for 2.0 and 3.5 (two different version numbers, though) - you should look at your project and see what version of the framework you're using. Commented Oct 4, 2010 at 16:47
  • It's 3.5 in project properties. Commented Oct 4, 2010 at 16:59
  • @dragonfly are you using the ScriptManager or UpdatePanel controls? Commented Oct 4, 2010 at 17:16

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

0

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 ....

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.