ASP.net RequiredFieldValidator not preventing postback

后端 未结 5 1106
猫巷女王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 10:52

    Validation can occur on the client if available, or on the server. The job of the validator isn't to prevent a postback, it's to validate the input.

    Make sure that you have javascript enabled, and try explicitly setting "EnableClientScript" to true.

    In the code-behind, you should never trust that the validators are validating on the client, and always use "if Page.IsValid".

提交回复
热议问题