开发者

Page_Validators is not defined

i am using asp.net routing

when using ValidatorEnable function in javascrip开发者_如何转开发t i got this error 'Page_Validators is not defined' how to solve this?

i am using this code in my global.asax file

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

routes.IgnoreRoute("{*allaspx}", new { allaspx = @".*\.aspx(/.*)?" });
routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });


I had the same issue.

I solved it by executing the code that uses Page_Validators from the $(document).ready event.


For anyone working with old code bases and hitting this all these years later.

You have little control over Page_Validators being defined. It's done by the Framework, so you're almost certainly calling one of the validator methods before WebUIValidation.js has had a chance to finish defining it.

In my case it was a very stupid thing: $(document).ready(myPageJs.Init()).

Amateur mistake, the () syntax means Init will execute right away, which in turn calls ValidatorEnable which was yet to be defined.

The fix being: $(document).ready(myPageJs.Init).

Init is now actually deferred and all is well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜