ASP.net RequiredFieldValidator not preventing postback

后端 未结 5 1095
猫巷女王i
猫巷女王i 2020-12-08 10:11

I have a question about what could stop a RequiredFieldValidator from preventing a postback.

I began working on an older, but simple aspx form and my predecessor use

5条回答
  •  借酒劲吻你
    2020-12-08 11:04

    Whew. Okay, I found the problem, basically by creating a brand new project and comparing its web.config line-by-line with my old project. Turns out the culprit is this:

     
    

    If I remove the line, my validation works the way I expected it to. Googling that uncovered a bunch of blog posts about how VisualStudio adds that line to the web.config when upgrading web apps from .net 1.1 to .net 3.5.

    The blog posts were mainly complaining about how that field interferes with .net's AJAX stuff, but I'm guessing it messes with the JavaScript emitted for the RequiredFieldValidator in a similar fashion.

提交回复
热议问题