2

I am doing some work on a legacy project, one that has been upgraded through the years from 1.1, to 2.0, and is now set at 3.5. Currently I am having some issues with required field validators not running when I click submit.

It's a pretty simple setup. I have two textboxes, I need both to be filled when a user clicks submit, I have RFV's pointing to each textbox but when I click the submit button the validation is not fired and then the resulting code bombs out. I have tried using both ValidationGroup on the relevant controls and also changing Display from "Dynamic" to "Static", with no results.

I've also had some issues when using AJAX controls where I get javascript errors and the like, which to me would point to an incorrect config regarding client-side libraries. Of course, I'm not really sure how to go about pinpointing the errors in my config. Any suggestions?

Thanks,

Mike

2
  • Here's something weird I just noticed. If I go into the event handler for the submit button's click event and add a work around (If myTextBox.Text <> "" Then ... ) then the page will post back and the validators will fire. If I remove it then the page bombs out. That's kind of confusing because if I understand how the lifecycle goes, it should perform server validation before executing a controls event code. Commented Feb 3, 2010 at 16:30
  • you need to show your html code. Commented Feb 3, 2010 at 16:44

4 Answers 4

2

As for the specific error, I am not sure, but I would caution you to modify your code to ensure that you do not have problems on the server side.

Add a check in your method to ensure that the validators are valid.

if(Page.IsValid)
{
    //Now do your thing
}
Sign up to request clarification or add additional context in comments.

1 Comment

I just happened to make a related comment above at about the same time :). When I add some code server side to check manually, then the validators will work (after postback, not client-side). When I remove it they break.
0

If you are receiving javascript errors, than that would be why your validation controls aren't firing.

Try using a tool called FireBug to pinpoint where your javascript errors are arising from.

1 Comment

I'm not actually getting Javascript errors in this particular case, but I have with some of the other client-side controls I would use which suggests to me that my client-side setup isn't exactly working properly. When I do get these errors it's usually somewhere deep inside a ScriptResource.axd?id=a121939d type script with some error like "Sys.Webforms Is Undefined" or "Object Expected" or some otherwise difficult to diagnose issue. Again, these aren't actually occuring in this particular case.
0

I found the solution while researching a similar problem on Telerik's support forum. The trick is to remove the tag <xhtmlConformance mode="Legacy"/> from the web.config as this somehow prevents the proper JS libraries from being loaded into the page.

Comments

0

While this isn't the answer to your case specifically, this is an answer to "Sys.WebForms is undefined", for which this link shows up in the top search results. So I want to include this answer, for anybody else who wasted 2 days trying to find the answer.

If the answer Mike C gave doesn't work for you, and you're using an obscure or newer browser, consider if the user-agent header being sent to ASP.Net is causing it to "disable" ajax.

In my case, this error only occurred on the iPad in full-screen mode. The answer was to tell ASP.Net that the browser supported ajax. I simply added this to my page's code behind:

protected override void OnPreInit(EventArgs e)
{
    if (Request.UserAgent != null && Request.UserAgent.IndexOf("AppleWebKit", StringComparison.CurrentCultureIgnoreCase) > -1)
    {
        this.ClientTarget = "uplevel";
    }

    base.OnPreInit(e);
}

For further details, see Sys.WebForms is undefined on iPad.

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.