Whether to use Page_IsValid or Page_ClientValidate() (for Client Side Events)

后端 未结 1 490
滥情空心
滥情空心 2020-12-16 04:21

I have following code inside a button click handler. Both approaches work fine. The Page_ClientValidate() causes an extra validation check and do processing whe

相关标签:
1条回答
  • 2020-12-16 05:01
    1. In case of button click, Page_ClientValidate() is called when (and only when) the button's CausesValidation is set to true.

    2. Page_ClientValidate() is part of process of doing postback, so it is called within button's click.
      I rely on Page_IsValid only in a scope of a function after calling Page_ClientValidate(). Otherwise I always call Page_ClientValidate().

    Comment: calling Page_ClientValidate() repeatedly may cause the page to be too obtrusive (multiple alerts etc.). That's why it's good to have a custom validate function that takes care of all validation.

    0 讨论(0)
提交回复
热议问题